Split collection description with split tag.

Solved
Highlighted
New Member
5 0 0

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. 

0 Likes
Highlighted

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.

0 Likes
Highlighted
New Member
5 0 0

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. 

0 Likes
Highlighted

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.

 

0 Likes
Highlighted
New Member
5 0 0

Thanks man. 

I did what you told me and now it works perfectly.

 

Have nice day and thanks!

0 Likes
Highlighted
Great to hear thank you came right!
0 Likes
Highlighted
Tourist
12 0 2

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

0 Likes
Highlighted

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

1 Like
Highlighted
Tourist
12 0 2

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

0 Likes
Highlighted
Tourist
12 0 2

This will work for the product description right?

0 Likes