Hello David,
I have this line i my header which shows up when a visitor is on the productpage and category page:
<?php print $template_topBarText; ?><?php print (isset($header["title"])?htmlspecialchars($header["title"],ENT_QUOTES,$config_charset)." voordeel":"")."";?>
Can you tell me how i can trim the title to 20 words?
And on my productpage i added the category with this code:
<?php if ($product_main["category"]): ?></a>
Categorie: <a href='<?php print $config_baseHREF."category/".tapestry_hyphenate($product_main["category"]);?>/'><?php print $product_main["category"]; ?>
I also like the category showed up in the befor this line:
<?php print $template_topBarText; ?><?php print (isset($header["title"])?htmlspecialchars($header["title"],ENT_QUOTES,$config_charset)." voordeel":"")."";?>
But when i place this code before it:
<?php print $product_main["category"]; ?>
nothing shows up.
Hello David,
When i use this code i get a white product page?
<?php
print $template_topBarText;
?>
<?php
if (isset($header["title"]))
{
$titleWords = explode(" ",$header["title"]);
$titleWords = array_slice($titleWords,0,20);
$title = implode(" ",$titleWords);
print htmlspecialchars($title,ENT_QUOTES,$config_charset)." voordeel";
?>
I can't see what is wrong.
Thanks Jan R
Hello Jan,
My apologies, I missed off the closing } in my original post - have a go with;
<?php
if (isset($header["title"]))
{
$titleWords = explode(" ",$header["title"]);
$titleWords = array_slice($titleWords,0,20);
$title = implode(" ",$titleWords);
print htmlspecialchars($title,ENT_QUOTES,$config_charset)." voordeel";
}
?>
(corrected above also)
Cheers,
David.
--
PriceTapestry.com
Hello Jan,
In your code where you would like to trim the title to 20 words (I assume this is a result of very long product names), you could do this:
<?php print $template_topBarText; ?>
<?php
if (isset($header["title"]))
{
$titleWords = explode(" ",$header["title"]);
$titleWords = array_slice($titleWords,0,20);
$title = implode(" ",$titleWords);
print htmlspecialchars($title,ENT_QUOTES,$config_charset)." voordeel";
}
?>
In your code where $product_main["category"] is not working, this is because $product_main is not yet in scope, so you would need to use:
<?php print $product["products"][0]["category"]; ?>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com