You know how every page in the shop has the same title (the name of your shop)? It's not so good when browsing history, because you can't know which page was which. Also, for SEO (search engine optimisation) it is good to have the product name in the page title.
I have found a way to accomplish this. It's a bit hacky, but it works thanks to the order in which the include files are read. It involves an extra database query for the product pages.
[readsettings.inc.php]
[find]
// some strings you might want to change
$slogan = $row[35];
$page_title = $row[36];
[/find]
[modify]
// some strings you might want to change
$slogan = $row[35];
$page_title = $row[36];
// Something extra to append to the title
if ($page != "") {
$page_title_extra = ucfirst(preg_replace('/[^a-zA-Z0-9- ]/', '', $page));
}
if ($page == "info" && $action != "") {
$page_title_extra .= " - " . ucfirst(preg_replace('/[^a-zA-Z0-9- ]/', '', $action));
}
if ($page == "details" && $prod != "") {
// Look up the product name in the database
$product_query = sprintf("SELECT `PRODUCTID` FROM `".$dbtablesprefix."product` where `ID`=%s", quote_smart($prod));
$product_sql = mysql_query($product_query) or die(mysql_error());
if (mysql_num_rows($product_sql) == 1) {
$product_row = mysql_fetch_row($product_sql);
$page_title_extra .= " - " . $product_row[0];
}
}
[/modify]
[/readsettings.inc.php]
The preg_replace strips out any nasty characters (like the ~ in the hidden 'extra' pages) and the ucfirst just ensures the first character is a capital letter.
Having done that, you can refer to $page_title_extra in your template:
<title><?php echo $page_title . " - " . $page_title_extra ?></title>
I'm attaching a screenshot as an example. It doesn't quite work because my computer doesn't seem to like taking screenshots of menus! But you can probably still see what the mod is doing.
Alternatively have a look at
www.sheabliss.co.uk to see it.
[attachment deleted by admin]