How to add short description on product list?

  • Posts: 16
  • Thank you received: 0
9 years 8 months ago #169266

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.1
-- PHP version -- : 5.3.28
-- Browser(s) name and version -- : safari 7.0.6

I swear I have looked for a while in the forum but didn't find the answer. I have looked carefully on the tutorial, documentation, topics and bug reports... :(

On my main product list page I would like to display a short description of each product. (before the add to cart button)
Didn't find any option in the settings.
Do I have to hack the display files?
Or is it because I'm running the Starter version? :(

Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 81633
  • Thank you received: 13085
  • MODERATOR
9 years 8 months ago #169281
The following user(s) said Thank You: Phil

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 0
9 years 8 months ago #170070

:P This might help others. It does the trick.

I have added the little hack in the listing_img_title file between end of product name and product price.
it displays 175 caracters from the regular description and replace last space by '...' and Read More.
you can manage class 'shortdesc' has you want.

I'm not pro so the hack can certainly be improved.

<!-- description -->
<div class="shortdesc">
<?php 
   $maxLength = 175;
   $longDesc = $this->row->product_description;
 if (strlen($longDesc)>$maxLength){
         $longDesc = substr($longDesc, 0, $maxLength);
         $position_espace = strrpos($longDesc, " ");
         $longDesc = substr($longDesc, 0, $position_espace);
         $longDesc = $longDesc." ... ";
 }
    echo $longDesc;                                                                
  	echo '<a href="'.$link.'">Read more</a>';
  ?>  
</div>
<!-- EO description -->

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 4 months ago #184160

hi there,

Im trying but didn´t get any result yet, just to confirm, you said in the liting_img_title but... from product, right?

cheers

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #184161

Hi,

Yes from product. But are you sure that you are using the "image and title" display type ?
You can check that in your menu / module settings.

www.hikashop.com/support/support/documen...ize-the-display.html

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 0
9 years 4 months ago #184175

naranjacuatro:

/components/com_hikashop/views/product/tmpl

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 4 months ago #184186

Hello! thanks a lot for answering so fast, I changed it but it doesn´t change anything...

I have "read more" enable in the shop, and a read more line in my product description...

is there anything else that needs to be changed? or just that...?
cheers!

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 4 months ago #184240

Hi there!
I got it now! ^_^

Just one last question... is there anything I can do in that file just to get image 2 more similar to image 1?
like... image to the left.. name and short description in the center and price to the right?

Because squares in image 2 are too big.. :-/

thanks a lot for your help :)

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81633
  • Thank you received: 13085
  • MODERATOR
9 years 4 months ago #184242

Hi,

You can edit the products listing menu/module via the menu Display>Content menus/modules and change the "type of layout" option to "table" and that should make it look similar.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 4 months ago #184376

but in that case "short description" is not shown... u^_^

Please Log in or Create an account to join the conversation.

  • Posts: 81633
  • Thank you received: 13085
  • MODERATOR
9 years 4 months ago #184381

Image 1.png doesn't have any description ;)

If you want to add the description on the products listing with a table layout, here is a thread about that:
www.hikashop.com/forum/4-how-to/75263-us...-in-productlist.html

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 4 months ago #184462

thanks! I´ll follow those steps :)

Please Log in or Create an account to join the conversation.

  • Posts: 281
  • Thank you received: 15
  • Hikashop Business
8 years 10 months ago #205519

Phil wrote: :P This might help others. It does the trick.

I have added the little hack in the listing_img_title file between end of product name and product price.
it displays 175 caracters from the regular description and replace last space by '...' and Read More.
you can manage class 'shortdesc' has you want.

I'm not pro so the hack can certainly be improved.

<!-- description -->
<div class="shortdesc">
<?php 
   $maxLength = 175;
   $longDesc = $this->row->product_description;
 if (strlen($longDesc)>$maxLength){
         $longDesc = substr($longDesc, 0, $maxLength);
         $position_espace = strrpos($longDesc, " ");
         $longDesc = substr($longDesc, 0, $position_espace);
         $longDesc = $longDesc." ... ";
 }
    echo $longDesc;                                                                
  	echo '<a href="'.$link.'">Read more</a>';
  ?>  
</div>
<!-- EO description -->


I use this code
<!-- description-->
<div class="shortdesc">
<?php 
   $maxLength = 90;
   $longDesc = $this->row->product_description;
 if (strlen($longDesc)>$maxLength){
         $longDesc = substr($longDesc, 0, $maxLength);
         $position_espace = strrpos($longDesc, " ");
         $longDesc = substr($longDesc, 0, $position_espace);
         $longDesc = $longDesc." ... ";
 }
    echo $longDesc;                                                                

  ?> 

</div>

And it works great.
Is any way to strip html tags?
Now if there is <strong> tag in first scentence and if it not closed before character limit, all site from there is bold.

Please Log in or Create an account to join the conversation.

  • Posts: 81633
  • Thank you received: 13085
  • MODERATOR
8 years 10 months ago #205537

Hi,

Change the line:
$longDesc = $this->row->product_description;
to:
$longDesc = strip_tags($this->row->product_description);

Please Log in or Create an account to join the conversation.

Time to create page: 0.120 seconds
Powered by Kunena Forum