Skip to main content

How to add short description on product list?

More
12 years 4 weeks ago #169266 by Phil
-- 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.

More
12 years 4 weeks ago #169281 by nicolas
The following user(s) said Thank You: Phil

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

More
12 years 3 weeks ago #170070 by Phil
: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.
Code:
<!-- 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.

More
11 years 9 months ago #184160 by naranjacuatro
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.

More
11 years 9 months ago #184161 by Xavier
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.

More
11 years 9 months ago #184175 by Tuscan Triangle
naranjacuatro:

/components/com_hikashop/views/product/tmpl

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

More
11 years 9 months ago #184186 by naranjacuatro
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.

More
11 years 9 months ago #184240 by naranjacuatro
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 :)

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

More
11 years 9 months ago #184242 by nicolas
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.

More
11 years 9 months ago #184376 by naranjacuatro
but in that case "short description" is not shown... u^_^

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

More
11 years 9 months ago #184381 by nicolas
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.

More
11 years 9 months ago #184462 by naranjacuatro
thanks! I´ll follow those steps :)

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

More
11 years 3 months ago #205519 by mojweb

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.

Code:
<!-- 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
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.

More
11 years 3 months ago #205537 by nicolas
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.238 seconds
Powered by Kunena Forum