Hey Justin!
I tried to implement your code step by step but somehow nothing is happening at all...
I found the template under sections, so I pasted the first snippet right before schema and then replaced the {{collection.description}} (found two of them) with the second snippet...
Do you maybe have an idea what could be the issue with that?
Thank you so much for your help,
Greetings Alex
I also copied my code for you to maybe take a look at it (I am using the debutify theme if it is of any importance to know):
Hi @taylorbs,
You can achieve this using CSS media queries to show everything above a certain screen width, then collapse only below a certain screen width. There are various other options besides width available as part of media queries as well, but width is probably the most commonly used to achieve mobile-only styles.
More info can be found here: https://www.w3schools.com/cssref/css3_pr_mediaquery.asp.
Hey Justin,
I've tried this solution for my site and it doesn't work quite right - the collection pages still display the full description, but with a "Read Less" link at the bottom which makes the description disappear completely.
Example page: https://carcologne.co.uk/collections/car-perfume-diffusers
Thanks in advance!
Dave.
So glad to have stumbled upon this thread! I have implemented this on a couple sites. On the site with only one collection description snippet on the page, it worked wonderfully. The second site is unique in that this specific collection page template is a category page which also lists sub categories and their descriptions.
It properly truncates and expands/collapses the first main description on the page. Sub category descriptions below that are truncated, but their read more tag controls the top/main collection description.
Any ideas on this? I assume it's because this solution wasn't initially crafted to deal with multiple collection descriptions being pulled into a main category page.
Here are the code samples:
Page: https://hartlyn.com/collections/spearfishing
First collection description (the one for the page; spearfishing)
<div id="collection-description" class="desktop-12 tablet-6 mobile-3 text-center">
<div id="bc-sf-filter-collection-description" class="rte">
<div id="truncated">{{ collection.description | strip_html | truncatewords: 30, "... <a class='read-more-collection' data-no-instant>Read More</a>" }}</div>
<div id="fullDescription" style="display: none">{{ collection.description | append: " <a class='read-more-collection' data-no-instant>Read Less</a>" }}</div>
</div>
</div>
That works perfectly.
Next, is the snippet which pulls in the sub categories and their descriptions, which does not work with the read more tag. The read more tag controls the above.
<div class="collection-index text-center">
<div class="section-title desktop-12 tablet-6 mobile-3 lines"><h2>{{ collection.title | escape }}</h2></div>
<div id="truncated">{{ collection.description | strip_html | truncatewords: 30, "... <a class='read-more-collection' data-no-instant>Read More</a>" }}</div>
<div id="fullDescription" style="display: none">{{ collection.description | append: " <a class='read-more-collection' data-no-instant>Read Less</a>" }}</div>
<div class="collection-carousel list-collection-carousel desktop-12 tablet-6 mobile-3" id="carousel-{{ section.id }}">
{% for product in collection.products limit: prod_limit %}
<div class="lazyOwl" id="product-listing-{{ product.id }}" data-alpha="{{ product.title }}" data-price="{{ product.price }}">
{% include 'product-listing' %}
</div>
{% endfor %}
</div>
<a class="collection-btn button" href="{{ collection.url }}" title="Shop All {{ collection.title }}">View All</a>
</div>
Any insight on this would be much appreciated! Also, the second above snippet is part of a loop on collections.
***EDIT***
I found a way to get the different read more paragraphs to work independent of each other, but it is sloppy as hell. I don't think it's the way to go. I was able to differentiate descriptions by giving them different ID's which would then require repeating the script over and over using slightly different identifiers.
I imagine there is a much slicker way to do this?
<!-- Begin Read More Tag -->
<style>
.read-more-collection:hover{cursor:pointer}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
var jq224 = jQuery.noConflict(true);
jq224('.read-more-collection').on('click', function(e){
e.preventDefault();
if (!jq224('#fullDescription').is(':visible')){
jq224('#truncated').fadeOut(300, function(){
jq224('#fullDescription').fadeIn(500);
});
}else{
jq224('#fullDescription').fadeOut(300, function(){
jq224('#truncated').fadeIn(500);
});
}
});
</script>
<style>
.read-more-collection-extra:hover{cursor:pointer}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
var jq224 = jQuery.noConflict(true);
jq224('.read-more-collection-extra').on('click', function(e){
e.preventDefault();
if (!jq224('#fullDescription-extra').is(':visible')){
jq224('#truncated-extra').fadeOut(300, function(){
jq224('#fullDescription-extra').fadeIn(500);
});
}else{
jq224('#fullDescription-extra').fadeOut(300, function(){
jq224('#truncated-extra').fadeIn(500);
});
}
});
</script>
<!-- End Read More Tag -->
Google will probably see this as pure trash.
Hi,
In case anyone needs help adding a "read more" button to the product page description on the Debut theme, I recently wrote a tutorial teaching how to achieve that. It can be found here.
Kind regards,
Diego
User | Count |
---|---|
415 | |
211 | |
103 | |
89 | |
86 |