Some retailers use extremely long descriptions (ie. Dabs),
I was wondering if there was any way to mod PT so that only XX amount of characters are imported from the description field (possibly to the end of a word?) and then ... or [more] (with a link to the product) is displayed at the end?
Cheers,
Nate
Can we also modify the descriptions on "category/some-category" and "search.php?q=some-keyword" to include a "..." after the description is cut off?
If so, how?
Thanks
Hi,
The description shown on the category/xxxx/ pages etc. (which is the same as the search results) is displayed by the following line in html/searchresults.php (line 20 in the distribution)
<p><?php print substr($product["description"],0,250); ?></p>
The easiest thing to do is just add "..." like this:
<p><?php print substr($product["description"],0,250); ?>...</p>
But perhaps a better alternative is to only print "..." if the length is greater than 250 characters:
<p><?php print substr($product["description"],0,250); if (strlen($product["description"]) > 250) print "..."; ?></p>
Hope this helps,
Cheers,
David.
Hello Nate,
The description used on the search results (as you're probably aware) is already truncated at 250 characters. The product page displays the full description.
If you want to limit the description forcefully during import; rather than use a filter it would be easier to modify the import routine directly. In includes/admin.php look for:
if ($admin_importFeed["field_description"])
{
...and add the following lines:
$breakLimit = 500;
if (strlen($record[$admin_importFeed["field_description"]]) > $breakLimit)
{
// find the first space after the limit
$breakOffset = strpos($record[$admin_importFeed["field_description"]]," ",$breakLimit);
// if found, crop the description and add "..."
if ($breakOffset !== false)
{
$record[$admin_importFeed["field_description"]] = substr($record[$admin_importFeed["field_description"]],0,$breakOffset)."...";
}
}
Simply change the value of $breakLimit for more or less descritpion!
Hope this helps,
Cheers,
David.