*

Smithtech

  • ****
  • 219 posts
Read More Button
« on: June 16, 2023, 11:38:09 PM »
Dear Team,

Please, can you help Implement the Epsilon Theme item description Read More... button  for category description read more?


Thank you


*

MB Themes

Re: Read More Button
« Reply #1 on: June 17, 2023, 01:07:02 PM »
Here we are not big fans of category descriptions :)
But oretry sure there are many guides for this on stackoverflow, as once you have function to get description, its just css & js
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Smithtech

  • ****
  • 219 posts
Re: Read More Button
« Reply #2 on: June 17, 2023, 08:52:56 PM »
Thank you very much.

Tried the function used for item description but it did not work.

*

Smithtech

  • ****
  • 219 posts
Re: Read More Button
« Reply #3 on: June 17, 2023, 10:45:45 PM »
Hi Team,

Sorry, I am able to display the category description with the function already.

The issue is that the category is a bit long so I would like to shorten it using ...Read more feature.

I also implemented the read more manually. But since this is a dynamic content, I am missing the connection even though I have seen that on item page for item description. I think I am not getting the function to do the read more for the category description right.

*

Smithtech

  • ****
  • 219 posts
Re: Read More Button
« Reply #4 on: June 17, 2023, 11:16:27 PM »
This code did the shortening
Code: [Select]
echo substr(strip_tags(@$cat['s_description']), 0, 720) . (strlen(strip_tags(@$cat['s_description'])) > 720 ? '...' : '');
This displayed the read more button:
Code: [Select]
<a href="#" class="read-more-desc"><?php _e('Read more''epsilon'); ?> <i class="fas fa-angle-down"></i></a>
But then how to display the rest of the content after the Read more button is clicked is the problem.

*

MB Themes

Re: Read More Button
« Reply #5 on: June 19, 2023, 08:23:37 AM »
@Smithtech
There are many ways.
We prefer something like this:
Code: [Select]
<div id="abox">
  <div class="short">short text <a href="#" class="readmore">Read more...</a></div>
  <div class="long">long text</div>
</div>

<script>
$('.readmore').click(function() {
  $(this).closest('.short').hide(0);
  $(this).closest('#abox').find('.long').show(0);
});
</script>
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Smithtech

  • ****
  • 219 posts
Re: Read More Button
« Reply #6 on: June 21, 2023, 02:00:59 AM »
Than you very much for the support.

This code did the work. Just that it does not keep formatting

Code: [Select]
        <script>
function myCustomReadmoreFunction() {
  var dots = document.getElementById("dots");
  var moreText = document.getElementById("mycustomreadmore");
  var btnText = document.getElementById("myCustomReadmoreBtn");

  if (dots.style.display === "none") {
    dots.style.display = "inline";
    btnText.innerHTML = "Read more";
    moreText.style.display = "none";
  } else {
    dots.style.display = "none";
    btnText.innerHTML = "Read less";
    moreText.style.display = "inline";
  }
}
</script>

Code: [Select]
<?php echo substr(strip_tags(@$cat['s_description']), 0720) . (strlen(strip_tags(@$cat['s_description'])) > 720 '...' ''); ?>
<span id="dots">...</span><span id="mycustomreadmore" style="display: none"  >
     
   </pr> <?php echo substr(strip_tags(@$cat['s_description']), 7209000020) . (strlen(strip_tags(@$cat['s_description'])) > 720 '' ''); ?>
     </span>
     <button onclick="myCustomReadmoreFunction()" id="myCustomReadmoreBtn" class="btn btn-transparent">Read more</button>


If you remove
Code: [Select]
strip_tags , all the content displays at once. The code doesn't work effectively. Aside that this code does the work just that the formatting is removed because of strip_tags

*

MB Themes

Re: Read More Button
« Reply #7 on: June 21, 2023, 11:47:10 AM »
If your description is formatted (richedit/tinymce), you need strip tags here otherwise you may cut your formatted code in middle that will break page design.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots