In some product feeds, the data is less than perfect. Sometimes long category names can crop up. So instead of the nice standard "MP3 Players", some merchants like to use "Consumer Electronics > Audio > MP3 Players". This can sometimes mess with your layout and just look plain ugly.
Around line 19 in atoz.php, change:
<?php
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
?>
to:
<?php
if (strlen($item["name"])>50)
{
print "<p><a href='".$item["href"]."' title='".ucwords(strtolower($item["name"]))."'>".ucwords(strtolower(substr($item["name"],0,50)))."...</a></p>";
} else {
print "<p><a href='".$item["href"]."' title='".ucwords(strtolower($item["name"]))."'>".ucwords(strtolower($item["name"]))."</a></p>";
}
?>
The changes made here are:
This may help someone somewhere!
Hi atman,
I can reply for Dave (hope he doesn't mind...!)
That's easy to do, instead of just using 50 on it's own, you can use the output from strpos() looking for a SPACE character with an offset of 50. Simply replace:
ucwords(strtolower(substr($item["name"],0,50)))
with:
ucwords(strtolower(substr($item["name"],0,strpos($item["name"]," ",50))))
Cheers,
David.
dbfcs,
is it possible to crop the category length 50 chacacters BUT if the 50th character falls in the middle of a word, the complete word would be displayed instead of cropping it in the middle. is this even posible?
thanks for sharing!, i am using your mod.