【问题标题】:Shopify - Product TabsShopify - 产品标签
【发布时间】:2020-09-08 14:31:52
【问题描述】:

我有以下代码向产品页面添加一个标签,它不会是静态的,也不会与所有其他产品相同。

<div id="tabs" class="htabs">
  <a href="#tab-description" class="selected">{{'products.product.description' | t}}</a>
  {%- if product.description contains "Videos" -%}
  <a href="#tab-video">
    {{ product.description | split: '<h6>' | last | remove: '<h6>' | split: '</h6>' | first}}
  </a>
  {%- endif -%}
  {%- if settings.reviews_enable -%}
  <a href="#tab-review" id="product-reviews-a" class="">{{'products.product.customer_reviews' | t}}</a>
  {%- endif -%}
  {%- if settings.product_tab_content_1 != blank -%}
  <a href="#tab-cus-1">{{ settings.product_tab_title_1 }}</a>
  {%- endif -%}
  {%- if settings.product_tab_content_2 != blank -%}
  <a href="#tab-cus-2">{{ settings.product_tab_title_2 }}</a>
  {%- endif -%}
  {%- if settings.product_tab_content_3 != blank -%}
  <a href="#tab-cus-3">{{ settings.product_tab_title_3 }}</a>
  {%- endif -%}
  {%- if settings.product_tab_content_4 != blank -%}
  <a href="#tab-cus-4">{{ settings.product_tab_title_4 }}</a>
  {%- endif -%}
</div>

<div id="tab-description" class="tab-content" itemprop="description
{{product.description}}</div>
<style>
@media screen and (min-width: 768px) {
  .tab-content {
    max-width: 80% !important;
    margin: 0 auto;
  }
}
</style>

{%- if product.description contains "Videos" -%}
<div id="tab-video" class="tab-content">{{ product.description | split: '<h6>' | last | remove: '<h6>' | split: '</h6>' | first}}</div>
{%- endif -%}
{%- if settings.reviews_enable -%}
<div id="tab-review" class="tab-content"><div id="shopify-product-reviews" data-id="{{product.id}}">{{product.metafields.spr.reviews}}</div></div>
{%- endif -%}  
{%- if settings.product_tab_content_1 != blank -%}
<div id="tab-cus-1" class="tab-content">{{- pages[settings.product_tab_content_1].content -}}</div>
{%- endif -%}
{%- if settings.product_tab_content_2 != blank -%}
<div id="tab-cus-2" class="tab-content">{{- pages[settings.product_tab_content_2].content -}}</div>
{%- endif -%}
{%- if settings.product_tab_content_3 != blank -%}
<div id="tab-cus-3" class="tab-content">{{- pages[settings.product_tab_content_3].content -}}</div>
{%- endif -%}
{%- if settings.product_tab_content_4 != blank -%}
<div id="tab-cus-4" class="tab-content">{{- pages[settings.product_tab_content_4].content -}}</div>
{%- endif -%}

所有其他选项卡默认由主题创建。 我要添加的是 “视频” 选项卡,但是如何在 “描述” 主选项卡中删除 &lt;h6&gt;Videos&lt;/h6&gt; 及其后面的任何文本? 我如何让&lt;h6&gt;Videos&lt;/h6&gt; 下的任何内容出现在'视频' 标签下?

当前输出:

视频不应显示在“描述”标签中。

如您所见,Hi 没有显示在 “视频” 选项卡中,也没有显示在我希望显示的位置。

【问题讨论】:

    标签: html css shopify


    【解决方案1】:

    对不起,别管我了。我得到它与以下工作:

    <div id="tabs" class="htabs">
      <a href="#tab-description" class="selected">{{'products.product.description' | t}}</a>
      {%- if product.description contains "Videos" -%}
      <a href="#tab-video">
        {{ product.description | split: '<h6>' | last | remove: '<h6>' | split: '</h6>' | first}}
      </a>
      {%- endif -%}
      {%- if settings.reviews_enable -%}
      <a href="#tab-review" id="product-reviews-a" class="">{{'products.product.customer_reviews' | t}}</a>
      {%- endif -%}
      {%- if settings.product_tab_content_1 != blank -%}
      <a href="#tab-cus-1">{{ settings.product_tab_title_1 }}</a>
      {%- endif -%}
      {%- if settings.product_tab_content_2 != blank -%}
      <a href="#tab-cus-2">{{ settings.product_tab_title_2 }}</a>
      {%- endif -%}
      {%- if settings.product_tab_content_3 != blank -%}
      <a href="#tab-cus-3">{{ settings.product_tab_title_3 }}</a>
      {%- endif -%}
      {%- if settings.product_tab_content_4 != blank -%}
      <a href="#tab-cus-4">{{ settings.product_tab_title_4 }}</a>
      {%- endif -%}
    </div>
    
    <div id="tab-description" class="tab-content" itemprop="description">{{product.description | split: '<h6>' | first | remove: '<h6>' }}</div></div>
    <style>
    @media screen and (min-width: 768px) {
      .tab-content {
        max-width: 80% !important;
        margin: 0 auto;
      }
    }
    </style>
    
    {%- if product.description contains "Videos" -%}
    <div id="tab-video" class="tab-content">{{product.description | split: '</h6>' | last }}</div>
    {%- endif -%}
    {%- if settings.reviews_enable -%}
    <div id="tab-review" class="tab-content"><div id="shopify-product-reviews" data-id="{{product.id}}">{{product.metafields.spr.reviews}}</div></div>
    {%- endif -%}  
    {%- if settings.product_tab_content_1 != blank -%}
    <div id="tab-cus-1" class="tab-content">{{- pages[settings.product_tab_content_1].content -}}</div>
    {%- endif -%}
    {%- if settings.product_tab_content_2 != blank -%}
    <div id="tab-cus-2" class="tab-content">{{- pages[settings.product_tab_content_2].content -}}</div>
    {%- endif -%}
    {%- if settings.product_tab_content_3 != blank -%}
    <div id="tab-cus-3" class="tab-content">{{- pages[settings.product_tab_content_3].content -}}</div>
    {%- endif -%}
    {%- if settings.product_tab_content_4 != blank -%}
    <div id="tab-cus-4" class="tab-content">{{- pages[settings.product_tab_content_4].content -}}</div>
    {%- endif -%}
    

    &lt;div id="tab-description" class="tab-content" itemprop="description"&gt;{{product.description | split: '&lt;h6&gt;' | first | remove: '&lt;h6&gt;' }}&lt;/div&gt;&lt;/div&gt;&lt;a href="#tab-video"&gt;{{ product.description | split: '&lt;h6&gt;' | last | remove: '&lt;h6&gt;' | split: '&lt;/h6&gt;' | first}}

    【讨论】:

      猜你喜欢
      • 2014-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      相关资源
      最近更新 更多