Add read more butto...
 
Notifications
Clear all

[Solved] Add read more button to the collection page

9 Posts
3 Users
4 Reactions
5,747 Views
Fanny-job
(@fanny-job)
Member
Joined: 4 years ago
Posts: 17
Topic starter  

Hi,

I am using Plak theme, on product page I have the read more button on the description, which is is great and very useful.

However, I don't see any option to add that button to the collection description, some of my collection descriptions are too long (for SEO purpose) and I need that toggle button to make it more user friendly.

Thanks in advance


   
Quote
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
 

Hi @fanny-job

Katrine here from Plak Theme support,

In order to add the (read more... read less) button on the collection description, I invite you to follow these steps :

 

  • From your Shopify dashboard, click Online store > Actions > Edit code
  • Open the file collection-template.liquid
  • Replace this code (it is duplicated 2 times)

{{ collection.description }}
  • With this one
         {% if collection.description.size > 700 %}
  <div class="product-description-short">
  {{ collection.description | truncate: 500, ". . . " }}<a class="readmore" href="#">Show More ></a>
  </div>
  <div class="product-description-full" style="display:none;">
  {{ collection.description }}
  <br><a class="readless" href="#">< Show Less</a>
  </div>
  {% else %}
    {{ collection.description }}
{% endif %} 
 
  • Just before this code
{% endpaginate %}
  • Add this one
  <script>
$('.readmore').click(function (event) {
event.preventDefault();
var descriptionFull = document.querySelector('.product-description-full');
descriptionFull.style.display = 'block';
var descriptionShort = document.querySelector('.product-description-short');
descriptionShort.style.display = 'none';
});
$('.readless').click(function (event) {
event.preventDefault();
var descriptionFull = document.querySelector('.product-description-full');
descriptionFull.style.display = 'none';
var descriptionShort = document.querySelector('.product-description-short');
descriptionShort.style.display = 'block';window.scrollTo({top: 110, behavior: 'smooth'});
})
</script>
  • Click Save

 

Let me know if it worked for you and if you need any further assistance with this feature.

Kind regards,
Katrine

Katrine | Technical support at Plak, Scrowp & Vantout
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as a Solved Solution


   
Fanny-job reacted
ReplyQuote
Fanny-job
(@fanny-job)
Member
Joined: 4 years ago
Posts: 17
Topic starter  

It works great ! Thanks a lot for the fast and accurate answer Katrine 🤩 🤩 🤩 😍 😍 😍 


   
plaktheme reacted
ReplyQuote
Aden Mott
(@adenmott)
Eminent Member
Joined: 3 years ago
Posts: 0
 

Hi Katrine, 

I actually also emailed Patrick this morning with questions about how to do this. I just went and edited the code as instructed but its not working on my website. I believe that is because I used the Plak editor to add the text content for my collection page rather than the Shopify editor because I wanted more flexibility with it should I ever decide to add more content. Is there a way to make it work this way also?

 

Thank you!


   
ReplyQuote
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
 
Posted by: @adenmott

Hi Katrine, 

I actually also emailed Patrick this morning with questions about how to do this. I just went and edited the code as instructed but its not working on my website. I believe that is because I used the Plak editor to add the text content for my collection page rather than the Shopify editor because I wanted more flexibility with it should I ever decide to add more content. Is there a way to make it work this way also?

 

Thank you!

Hi Aden,

I've just checked you conversation with Patrick from the email support, I will check your website and get back to asap 🙂

Katrine | Technical support at Plak, Scrowp & Vantout
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as a Solved Solution


   
ReplyQuote
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
 

I checked out your website Aden, it seems you have used the Rich text section in the collection page, and as you guessed 🤗 , this is why the code above didn't work for you. 😑 

Anyway, I made some changes in the rich text section, and the readmore/less buttons works great on your store now.

If you have any other questions or issues, feel free to let me know 🙂

Katrine

Katrine | Technical support at Plak, Scrowp & Vantout
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as a Solved Solution


   
ReplyQuote
Aden Mott
(@adenmott)
Eminent Member
Joined: 3 years ago
Posts: 0
 

@plaktheme  I just reverted back to the theme saved before this fix.  I didn't realize that the rich text I added for the one collection I needed it in was actually added to "default collection", which showed the rich text on every collection page. Is there a way to edit each collection individually inside the Plak editor?

This post was modified 3 years ago by Aden Mott

   
ReplyQuote
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
 
Posted by: @adenmott

@plaktheme  I just reverted back to the theme saved before this fix.  I didn't realize that the rich text I added for the one collection I needed it in was actually added to "default collection", which showed the rich text on every collection page. Is there a way to edit each collection individually inside the Plak editor?

Any changes you make from the theme editor to your collection page will affect the others, since you are using a default collection templates on all of them.

In order to have different content for each collection page, I invite you to follow this TUTORIAL that I have just created 🙂

Let me know if you have any additional questions regarding this topic 🙂

Katrine

Katrine | Technical support at Plak, Scrowp & Vantout
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as a Solved Solution


   
ReplyQuote
Aden Mott
(@adenmott)
Eminent Member
Joined: 3 years ago
Posts: 0
 

@plaktheme Thank you so much for the top-notch support!


   
Fanny-job and plaktheme reacted
ReplyQuote
Share:

Welcome to the Shopify Forum Community provided by Plak ThemeLLC, a place where you can discuss about eCommerce and Shopify, solve technical issues, get help with Shopify Design, Apps integration, Marketing, Facebooks ad, Google ads and more.

Before posting, we invite you to read and follow the forum rules | We also support any questions related to Free Shopify themes :Dawn, Express, Minimal, Brooklyn, Narrative, Supply, Debut, Venture, Boundless and Simple