New to this board and working on a couple of sites at the moment. I am trying to extend the truncated text in the product listings - where you can view by list or grid so we can get a full sentence in there and it doesn't get cut off (in list view).
Trying to avoid this sort of thing: Vivaspin centrifugal concentrators are disposable ultrafiltration devices for the concentration o..
Hope you can help - am working in 1.5.1
Cheers
Tim
Trying to avoid this sort of thing: Vivaspin centrifugal concentrators are disposable ultrafiltration devices for the concentration o..
Hope you can help - am working in 1.5.1
Cheers
Tim
Hi Tim. Here's a little function you can use (put it at the top of the template file
Then for the text, you just wrap it in parentheses and put get_words before it, optionally specifying the word count
For example, you could change
to
Code: Select all
<?php
if(!function_exists('get_snippet')) {
function get_snippet($sentence, $count = 5, $separator = ' ') {
$count = (int) $count;
if(!$count) return '';
$words = array_chunk(explode($separator, $sentence), $count);
return implode($separator, $words[0]);
}
}
?>
For example, you could change
Code: Select all
<?php echo $product['description']; ?>
Code: Select all
<?php echo get_snippet($product['description'], 15); ?>
Thanks for the rapid reply Jay - sorry don't want to break it, so which file do you change? Sorry to ask but am new to this.
Thanks Tim
Thanks Tim
It depends which page. The main ones I'm guessing will be
Code: Select all
/catalog/view/theme/your-theme-name/template/product/product.tpl
/catalog/view/theme/your-theme-name/template/product/category.tpl
/catalog/view/theme/your-theme-name/template/product/manufacturer_info.tpl
/catalog/view/theme/your-theme-name/template/product/search.tpl
Thanks for the input - have been working on the category.tpl. The code seems to work to shorten the number of words - ie less than 15 - if I increase this number nothing seems to happen.
ie <?php echo get_snippet($product['description'], 30); ?>
Perhaps there is something else preventing any more words to be added. Test site is
generonshop.co.uk/generon - still work in progress.
ie <?php echo get_snippet($product['description'], 30); ?>
Perhaps there is something else preventing any more words to be added. Test site is
generonshop.co.uk/generon - still work in progress.
Hi Jay - thanks for all your help on this. Go to:
http://generonshop.co.uk/generon/index. ... path=71_72
You will see the description at the top that is being used for all this range of products at the moment.
The full description:
The BJP concentrates urine through the absorption of water by absorbent pads located on the underside of an ultrafiltration membrane. Bence Jones protein will be retained on the membrane surface in the front compartment of the BJP unit because it has a 7.5 kDa MWCO membrane, a molecular weight cut-off far from the molecular weight of Bence Jones protein itself.
The truncated text cuts as:
The BJP concentrates urine through the absorption of water by absorbent pads located on the under..
It's 15 + a bit words - perhaps I am referring to the wrong text or something?
Cheers
Tim
http://generonshop.co.uk/generon/index. ... path=71_72
You will see the description at the top that is being used for all this range of products at the moment.
The full description:
The BJP concentrates urine through the absorption of water by absorbent pads located on the underside of an ultrafiltration membrane. Bence Jones protein will be retained on the membrane surface in the front compartment of the BJP unit because it has a 7.5 kDa MWCO membrane, a molecular weight cut-off far from the molecular weight of Bence Jones protein itself.
The truncated text cuts as:
The BJP concentrates urine through the absorption of water by absorbent pads located on the under..
It's 15 + a bit words - perhaps I am referring to the wrong text or something?
Cheers
Tim
Last question before I abandon this ;-) - am playing with CSS in firebug - could this tweaked to show more or even have no description snippet at all to clean the listings up? Thanks T
The file in question you'd like to update is: /catalog/controller/product/category.php
Line 186:
Change to:
Increasing the number of parsed characters from 100 to 900 (or whatever you need it to, and if you add ending punctuation in your descriptions, remove the and change it to , to remove the trailing ellipses.
Hope it helps!
Line 186:
Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 900) . '',
Code: Select all
'..'
Code: Select all
''
Hope it helps!
Thank you.
But, in your opinion ther is a problem of duplicate content now, between product and category page?
But, in your opinion ther is a problem of duplicate content now, between product and category page?
Sigaretta elettronica Opencart 1.5.4.1 italian translation
Thanks for the input - will have a look at some point again. Been diverted onto other areas of Opencart to modify now!
Cheers
Cheers
I have been looking for a similar solution and followed travoltron php change to allow full description text (no truncation) in list view which is great but I would also like to show the audio player in list view that I have in full product view>source>html.
e.g.
<p>
<object data="dewplayer.swf" height="20" id="dewplayer" name="dewplayer" type="application/x-shockwave-flash" width="200"><param name="movie" value="dewplayer.swf" /><param name="flashvars" value="mp3=../sampleguitar/mp3/test1.mp3" /><param name="wmode" value="transparent" /></object></p>
Is it possible to show the individual product audio flash player in the List view?
Any help greatly appreciated!
Toby
e.g.
<p>
<object data="dewplayer.swf" height="20" id="dewplayer" name="dewplayer" type="application/x-shockwave-flash" width="200"><param name="movie" value="dewplayer.swf" /><param name="flashvars" value="mp3=../sampleguitar/mp3/test1.mp3" /><param name="wmode" value="transparent" /></object></p>
Is it possible to show the individual product audio flash player in the List view?
Any help greatly appreciated!
Toby
To stop/edit trunctation of product description in OpenCart 1.5.6
In catalog/controller/product/category.php
search for the line
then
change :
to:
the 999 is the number of characters that will display before being truncated, so alter this to suit yourself
The . '..' at the end of the original line is what displays after truncation,
so if you wanted truncation, but not the default dots you could to amend this to e.g. this would be the place to do it.
In catalog/controller/product/category.php
search for the line
Code: Select all
$this->data['products'][] = array(
change :
Code: Select all
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
Code: Select all
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 999),
The . '..' at the end of the original line is what displays after truncation,
so if you wanted truncation, but not the default dots you could to amend this to e.g.
Code: Select all
. '... more...'
Finally I managed to find a solution to this and it's working beautifully.
I know this is an old thread but there might be people who still use OpenCart 1.5.6.4.
Also I wanted to make a contribution to the community.
So .... in order to truncate the description text in product lists to only to full words, and only if the initial string's length is larger than the wanted one, here is the new code.
Find in:
in catalog/controller/product/ folder, in these 4 files:
category.php
manufacturer.php
search.php
special.php
the following line:
(assuming 100 is the default value, if not, search only for the first part of the line)
And replace with:
Adjust the 400 value to your needs. Keep in mind that, using the default layout / template, the product listing in category has a lower width (because on one side there is the categories column), and in product, search and special has the full with of the content column.
Depending on the font used, you might get 2 1/2 rows of text in special.php, search.php and manufacturer.php using a value of 400 and a little more than that using 350 in category.php
I know this is an old thread but there might be people who still use OpenCart 1.5.6.4.
Also I wanted to make a contribution to the community.
So .... in order to truncate the description text in product lists to only to full words, and only if the initial string's length is larger than the wanted one, here is the new code.
Find in:
in catalog/controller/product/ folder, in these 4 files:
category.php
manufacturer.php
search.php
special.php
the following line:
Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
And replace with:
Code: Select all
'description' => (strlen(utf8_decode(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))))> 400 ? mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, mb_strrpos(mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 400, 'UTF-8'), ' ', 0, 'UTF-8'), 'UTF-8') : strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))) . '...',
Depending on the font used, you might get 2 1/2 rows of text in special.php, search.php and manufacturer.php using a value of 400 and a little more than that using 350 in category.php
I just tried it with the files, and it seems to work well in my latest v.1.5.6.5_rc Test Shop. And looks much better too !
It only does not work on the product Page, for related items, where I added a $desc Variable - calling the $description Value, to add the Description to the related items also. So, I modified your 'content' accordingly, to match the above variable, but there, it presents an error, and the entire page does not longer display. But since I don't need to have it in the related Products, because of lots of free space, I just don't use it there anyway!
Sample Page:
http://www.gratis-anzeiger.com/shop/ind ... ry&path=33
Don't look at the Words, or try to understand the meaning, they are auto-generated!
Still, Google, Amazon, & Co. seemengly indexes them, on a steady pace!
Thank you !
Ernie
PS: OC v.1.5.6.x is not old, it's just grown-up!
http://www.merriam-webster.com/dictiona ... E2%80%93up
It only does not work on the product Page, for related items, where I added a $desc Variable - calling the $description Value, to add the Description to the related items also. So, I modified your 'content' accordingly, to match the above variable, but there, it presents an error, and the entire page does not longer display. But since I don't need to have it in the related Products, because of lots of free space, I just don't use it there anyway!
Code: Select all
'desc' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 240) . '.',
http://www.gratis-anzeiger.com/shop/ind ... ry&path=33
Don't look at the Words, or try to understand the meaning, they are auto-generated!
Still, Google, Amazon, & Co. seemengly indexes them, on a steady pace!
Thank you !
Ernie
PS: OC v.1.5.6.x is not old, it's just grown-up!
http://www.merriam-webster.com/dictiona ... E2%80%93up
My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Who is online
Users browsing this forum: No registered users and 207 guests