Hi David
I have been following a few examples, but I can't seem to get it right.
What I am trying to do is, in the META TITLE display something like "Buy this product from [merchant]" on the search.php page. Can this be done?
I seem to have been able to half do it on the description using:
$header["meta"]["description"] = "Buy the IRON MAN Game from ".htmlentities($q,ENT_QUOTES,$config_charset);
<title>Gameseek </title>
<meta name='description' content='Buy the IRON MAN Game from merchant:Gameseek:' />
But can't get this to work at all on the title.
Would it also be very difficult to do on the products.php page "Buy [Product] from [Cheapest Merchant]"
many thanks
kelly
Hi David,
I'm getting the error message:
Parse error: syntax error, unexpected ']' in /content/DesignerPlus/i/r/ironmangame.co.uk/web/search.php on line 2
When I take out the ']' my description looks like this
<meta name='description' content='Buy the IRON MAN Game from ' />
To make this appear as the title is it just a case of changing ["description'] to ['title"]?
regards
Kelly
www.ironmangame.co.uk
Hi Kelly,
I corrected the code above; but i'm not sure why $parts[1] is coming across as empty when $parts[0] is set. Could you perhaps email me your modified search.php and i'll take a look? Reply to your reg code or forum registration email is the easiest way to get me....
Regarding the title, look for the following line in search.php:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
...so you can replace this with the code above replacing $header["meta"]["description"] with just $header["title"]....
Cheers,
David.
Many thanks for your help David, all now seems to be functioning using:
$header["title"] = "Buy the IRON MAN Game from ".htmlentities($q,ENT_QUOTES,$config_charset);
if ($parts[0] == "merchant")
{
$header["meta"]["description"] = "Buy the IRON MAN Game from ".htmlentities($parts[1],ENT_QUOTES,$config_charset);
}
$header["meta"]["keywords"] = "ironman game, iron man, Xbox, PS3, PS2 Playstation, PC, Nintendo Wii, DS, PSP.";
I think the problem was I was putting it all in the wrong part of the page. Needed to be from line 156 on search.php
I'll be in touch if I have any probs with the product.php bit :-)
Kelly & Stuart
www.ironmangame.co.uk
Hi Kelly,
For search.php, there isn't normally a specific product, but you can certainly set this style of header tag (assuming that you want IRON MAN as a constant for every merchant search page). I would make it conditional upon a merchant: query, which you can spot by looking at the $parts[0], at which point you can also use the merchant name on its own by using the $parts[1] variable:
if ($parts[0] == "merchant")
{
$header["meta"]["description"] = "Buy the IRON MAN Game from ".htmlentities($parts[1],ENT_QUOTES,$config_charset);
}
For product.php, the cheapest merchant will be in the $product["products"][0]["merchant"] variable at the time the meta description tag is generated, so you could replace the following code (line 52 in the distribution):
$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
...with:
$header["meta"]["description"] = "Buy ".htmlentities($q,ENT_QUOTES,$config_charset)." from ".htmlentities($product["products"][0]["merchant"],ENT_QUOTES,$config_charset);
Cheers,
David.