Liquid, JavaScript, themes, sales channels
Hi,
I've searched and searched but with no luck.
I want to have a long description and a short on.
I went to the collection.liquid template which says following:
{% section 'collection-template' %}
{% section 'recently-viewed-products' %}
{% section 'collection-footer' %}
So i got to collection-template. Here i want to replace collection.description with:
{% assign descriptions = collection.description | split: "<!-- split -->" %} {% assign short_desc = descriptions[0] %} {% assign long_desc = descriptions[1] %}
But i'm unsure how to replace it because it says:
{%- if collection.description != blank -%}
<div class="SectionHeader__Description Rte">
{{- collection.description -}}
{{ short_desc }}
</div>
{%- endif -%}
</div>
</div>
</header>
</div>
{%- else -%}
<header class="PageHeader">
<div class="Container">
<div class="SectionHeader SectionHeader--center">
<h1 class="SectionHeader__Heading Heading u-h1">{{ collection.title }}</h1>
{%- if collection.description != blank -%}
<div class="SectionHeader__Description Rte">
{{- collection.description -}}
</div>
{%- endif -%}
</div>
</div>
</header>
{%- endif -%}
{%- endif -%}
How should i replace collection description?
And how do it put in the {{ short_desc }} and {{ long_desc }}?
Thanks.
Solved! Go to the solution
This is an accepted solution.
Hi Jenno
nNo problem, however this will obviously limit the support I can give you. Add the section of code you linked here at the top of your collection-template.liquid file. Then search for each line in the file that looks as follows:
{{- collection.description -}}
Replace each of these with either {{ short_desc }} or {{ long_desc }} as desired.
When the lines you are looking for are inside a if statement, make sure you replace the description in both the if part and the else part of the if statement with the same new code.
Hope this helps. If not, your welcome to also send me a private message if you prefer with the full collections-template.liquid file code and I will tell you which lines to replace with which code.
Hi Jenno. Walter here from microDev (Shopify Partner).
Your code for splitting the description will work find in terms of assigning the variables short_desc and long_desc. However, I am not sure about where on your collection page you want to place the short description and the long description. I think the easiest may be to send me an email at support@microdev.today with the URL of your shopify store (the yourstore.myshopify.com one) and then I will request access to your store and have a look at exactly what you are trying to do. If it is as it sounds, I’d be happy to do this free-of-charge for you.
if you want with any other customisations as well, I’d be happy to let you know how we could help you achieve them.
Thanks for the response.
I'm feeling unsure about giving you access to our shop and I rather do it myself 🙂
Can you tell me what to do with assigning the variables in the template? Since the collection.description are in the IF statements, i'm unsure how to replace the assignment.
I'll figure out the placement of the output of the arrays.
This is an accepted solution.
Hi Jenno
nNo problem, however this will obviously limit the support I can give you. Add the section of code you linked here at the top of your collection-template.liquid file. Then search for each line in the file that looks as follows:
{{- collection.description -}}
Replace each of these with either {{ short_desc }} or {{ long_desc }} as desired.
When the lines you are looking for are inside a if statement, make sure you replace the description in both the if part and the else part of the if statement with the same new code.
Hope this helps. If not, your welcome to also send me a private message if you prefer with the full collections-template.liquid file code and I will tell you which lines to replace with which code.
Thanks man.
I did what you told me and now it works perfectly.
Have nice day and thanks!
Hi, could you help me too? I need to split the description of my product page in two as well but not longer and shorter but to look even and good. What should I do? You're the best
Hi kenyamuro
Have you followed the advice/instructions above? If you have and you are still not coming right, drop me an email at support@microdev.today with the shopify url for your website and I can take a look at where you went wrong and help you get it the way you would like it.
Yours Sincerely
Walter
Thanks for replying so fast. This is for a client and she wants it done tonight so thanks so much for answering. I am just not sure where in the code to paste what you shared above, I am using the turbo theme from outofthesandbox if that helps.
Thanks again,
Kenya
This will work for the product description right?
Hey man thanks for helping us all out!
My theme is a little different, the out of the sandbox flex theme 3.2.1.
I don't have the collection-template.liquid file and the collection.description code is a comment in my collection__main.liquid file, as you can see in the screenshot:
Would love if you could guide me how to go about getting this implemented on my store.
Thanks in advance!
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024