Hi,
I'm creating a custom install for a client and am trying to pull a shortened version of the product description into the homepage and search page.
Is there a simple way to do this that doesn't requite database fiddling? I've gone through the controllers but probably missed something as I'm not very good with php...
thanks
I'm creating a custom install for a client and am trying to pull a shortened version of the product description into the homepage and search page.
Is there a simple way to do this that doesn't requite database fiddling? I've gone through the controllers but probably missed something as I'm not very good with php...
thanks
Hi,
In the display area (template) use something like this:
Replace description with the name of the field you wish to truncate and the 25 with the number of characters you want to display before the ellipse ...
Phil.
In the display area (template) use something like this:
Code: Select all
substr(strip_tags($query->row['description']),0,25) . "..."
Phil.
That's the sort of thing I need, just I can't get the description to be pulled onto the pages I need, I tried this:
but it doesn't work - I'm guessing that I need to make a more fundamental change somewhere?
Code: Select all
<?php echo $products[$j]['description']; ?>
I am trying this right now, but I am not a php-coderphpuk wrote:Hi,
In the display area (template) use something like this:
Replace description with the name of the field you wish to truncate and the 25 with the number of characters you want to display before the ellipse ...Code: Select all
substr(strip_tags($query->row['description']),0,25) . "..."
Phil.
In catalog/controller/product/product.php around line 133 i inserted
Code: Select all
'short_description' => substr(strip_tags($result['description']),0,50). "...",
Code: Select all
<?php echo $products[$j]['short_description']; ?>
Could any of you PHP-Guys please give me a hint?
Help's appreciated,
Thanks
Claus
Try this instead...
Your above edits to the files don't seem to add up though... you need the make changes to category.php and category.tpl.
The category.tpl doesn't appear in controller/product/product.php as far as I can see.
Let me know if this works for you.
Code: Select all
'shortdescription' => html_entity_decode(substr($result['description'],0,50))."...",
The category.tpl doesn't appear in controller/product/product.php as far as I can see.
Let me know if this works for you.
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
Sorry, that was a typo. I meant to say that I edited both, the category.php and category.tpl and it basically works. My Problem is that the tags are NOT being stripped.
It's rather a lack of basic PHP-Knowledge-Kind-Of-Problem. If anybody could just give me a hint where to look for the problem I would try to find my way through.
Thank you in advance,
Claus
It's rather a lack of basic PHP-Knowledge-Kind-Of-Problem. If anybody could just give me a hint where to look for the problem I would try to find my way through.
Thank you in advance,
Claus
Did this work for you? I'll post the files you need if you are still having issues.
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
Hi Readyman,
Im just wondering if you have a better solution to this issue. I followed instructions and came across some issues. One issue was it displays the text as is; that is to say if your first line of text is bold it will display bold in the short description, obviously the first line may change from bold to normal for different product descriptions, so it doesnt look good. Another issue I found was the 1st product to display a short description either failed to do so or displayed something weird. Another was the short description doesnt seem to get passed a carriage return in the main description and so stops short.
What would be perfect was if I could enter a short description in admin to be displayed. How would I go about this?
Thanks in advance!
Im just wondering if you have a better solution to this issue. I followed instructions and came across some issues. One issue was it displays the text as is; that is to say if your first line of text is bold it will display bold in the short description, obviously the first line may change from bold to normal for different product descriptions, so it doesnt look good. Another issue I found was the 1st product to display a short description either failed to do so or displayed something weird. Another was the short description doesnt seem to get passed a carriage return in the main description and so stops short.
What would be perfect was if I could enter a short description in admin to be displayed. How would I go about this?
Thanks in advance!
OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods
@thepath - I'll look into adding a "short description" add-on.
It will require:
- adding a field in the database for the 'product summary'
- making the field in the admin pages to add content to it.
- retrieving and putting the summary in the product list in the front end.
Pretty straight forward.
@d33p - custom fields in the description? Sounds like it's something else entirely - can you elaborate on that one?
It will require:
- adding a field in the database for the 'product summary'
- making the field in the admin pages to add content to it.
- retrieving and putting the summary in the product list in the front end.
Pretty straight forward.
@d33p - custom fields in the description? Sounds like it's something else entirely - can you elaborate on that one?
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
Nice one readyamn!
Simple for those familiar with the opencart structure and well versed in php. For a dumb bum like moi however not so straight forward Im afraid. Waaaa
Simple for those familiar with the opencart structure and well versed in php. For a dumb bum like moi however not so straight forward Im afraid. Waaaa
OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods
Yep that's correct, it's exactly the same as the meta tag description, but it will just display in a different part of the template to just give you more control.
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
Hey Readyman just wondering if there was any progress on this one.
Cheers
Cheers
OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods
I am also wondering how to get a short description to display on the homepage, has anyone had any joy with this?
Helen
Helen
1a. If using 1.4.8 or later, EDIT: catalog/controller/module/latest.php
1b. If using 1.4.7 or earlier, EDIT: catalog/controller/common/home.php
2. FIND:
3. AFTER, ADD:
4a. If using 1.4.8 or later, EDIT: catalog/view/theme/default/template/module/latest_home.tpl
4b. If using 1.4.7 or earlier, EDIT: catalog/view/theme/default/template/common/home.tpl
5. FIND:
6. BEFORE, ADD:
1b. If using 1.4.7 or earlier, EDIT: catalog/controller/common/home.php
2. FIND:
Code: Select all
'name' => $result['name'],
Code: Select all
'description' => strip_tags(substr(html_entity_decode($result['description']),0,80))."...",
4b. If using 1.4.7 or earlier, EDIT: catalog/view/theme/default/template/common/home.tpl
5. FIND:
Code: Select all
<?php if ($display_price) { ?>
Code: Select all
<?php echo $products[$j]['description']; ?>
Who is online
Users browsing this forum: No registered users and 33 guests