Read more/less butt...
 
Notifications
Clear all

Read more/less button on Debut theme collection page

8 Posts
3 Users
2 Reactions
1,596 Views
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
Topic starter  

Hi,

If you have a long description on your Debut theme collection page, it is recommended to use a read more/ read less button to make the description look shorter and let visitors see your other content (such as your products) and let them see the full description by simply clicking on the read more button.

 

This short tutorial allows you to add the read more/ read less button on Debut theme without using any app :

 

  • 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 src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<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

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


   
Quote
(@bogdanu)
New Member
Joined: 3 years ago
Posts: 4
 

Hello, thanks a lot. It worked for the collection page. What ca i do for product description page? It shwon the See more button but nothing happened when i click it. Can you help me> Thanks a lot


   
plaktheme reacted
ReplyQuote
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
Topic starter  
Posted by: @bogdanu

Hello, thanks a lot. It worked for the collection page. What ca i do for product description page? It shwon the See more button but nothing happened when i click it. Can you help me> Thanks a lot

Hi @bogdanu

In order to add a functional read more/less button on Debut theme product page, I invite you to follow these steps :

 

  • From your Shopify dashboard, click Online store > Actions > Edit code
  • Open the file product-template.liquid
  • Replace this code
{{ product.description }}
  • With this one
{% if product.description.size > 700 %}
<div class="product-description-short">
{{ product.description | truncate: 500, ". . . " }}<a class="readmore" href="#">Show More ></a>
</div>
<div class="product-description-full" style="display:none;">
{{ product.description }}
<br><a class="readless" href="#">< Show Less</a>
</div>
{% else %}
{{ product.description }}
{% endif %}

  • Just before this code
{% schema %}
  • Add this one
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<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 you need any further help with this feature 🙂

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
(@bogdanu)
New Member
Joined: 3 years ago
Posts: 4
 

Wow. Thank you so much. Now, the button its working very well, but, i still having 1 little issue

I have only one issue now. The Show less button doesnt appear at the end of the description

 

This post was modified 3 years ago by BogdanU

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

Wow. Thank you so much. Now, the button its working very well, but, i still having 1 little issue

I have only one issue now. The Show less button doesnt appear at the end of the description

 

Are you sure you are using Debut theme ?

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
(@bogdanu)
New Member
Joined: 3 years ago
Posts: 4
 

Yes, i am using the debute theme. And also, the description doubles after i press the View More button.

 



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

Yes, i am using the debute theme. And also, the description doubles after i press the View More button.

 


I think there is a conflict with a third party app or the code is altered, try to insert this feature on a fresh version of Debut theme and check if it works.

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


   
BogdanU reacted
ReplyQuote
(@bogdanu)
New Member
Joined: 3 years ago
Posts: 4
 

Indeed, it was a conflict with a third party app. Now everything is super ok. Thankyou so so much. You are amazing


   
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