Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

html - How can i alter a div in my shopify theme to populate text from my product description

can anyone offer assistance on how I can alter a product page with individual tabs at the bottom (full description, delivery, returns info) In this case (size chart) is what i'm implementing. I need to get text from my product description which houses the size chart at the bottom of the description's paragraph.

presume i will need to use some type of html tag on my product description editor to signal where to split the text like a "!-- split -->" move. but i also need to add something into my custom tabs div? which is below

        {% if section.settings.product_customtabs_1 %}       
        <div id="collapse-tab3" class="tab-pane fade">
          {% include 'display_product_detail_description' %}
          {% if settings.enable_multilang %}
          <div class="lang1">{{ section.settings.product_customtabs_content_1 | split: '|' | first }}</div>
          <div class="lang2">{{ section.settings.product_customtabs_content_1 | split: '|' | last   }}</div>
          {% else %}
          {{ section.settings.product_customtabs_content_1 | split: '|' | first  }}
          {% endif %}
        </div>
        {% endif %}

am i going about this all wrong?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you can use the custom HTML tag like <!-- split --> between backend product description editor and then separate the content over product page easily using liquid code filters.

{% assign productDes = product.description | split:'<!-- split -->' %}
{% assign productDesPart1 = productDes[0] %}
{% assign productDesPart2 = productDes[1] %}

you can use the first]and last array filters first to get the values, but it works when there is a single <!-- split --> is used.

{% assign productDesPart1 = product.description | split:'<!-- split -->' | first %}
{% assign productDesPart2 = product.description | split:'<!-- split -->' | last %}

you can use something like this, but careful with the HTML tag into the backend editor and liquid code are some otherwise is not works.

enter image description here enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...