You are here:  » Search.php $banner["h1"] = translate

Support Forum



Search.php $banner["h1"] = translate

Submitted by webie on Tue, 2009-08-25 09:58 in

Hi Dave,

How would i go about changing the $banner["h1"] = translate based on type of search?

Example:

if category:$q:
$banner["h1"] = translate 'CAT Meta Details';

elseif merchant:$q:
$banner["h1"] = translate 'Merchant Meta Details';

elseif "brand:$q:
$banner["h1"] = translate 'Brand Meta Details';

else "$q"
$banner["h1"] = translate 'Default Search H1';

Kind Regards

Darren

Submitted by support on Tue, 2009-08-25 11:17

Hi Darren,

All you need to do is set $banner["h1"] (which is assume is part of a customisation as the distribution only uses h2 and h3) based on a switch statement inspecting $parts[0]; which may contain "category", "brand", "merchant" - and if so; $parts[1] would contain the actual data. For example (ignoring translate which is only necessary if you are actually translating existing strings):

switch($parts[0])
{
  case "merchant":
    $banner["h1"] = "Merchant info for ".htmlentities($parts[1],ENT_QUOTES,$config_charset);
    break;
  case "category":
    $banner["h1"] = "Category info for ".htmlentities($parts[1],ENT_QUOTES,$config_charset);
    break;
  case "brand":
    $banner["h1"] = "Brand info for ".htmlentities($parts[1],ENT_QUOTES,$config_charset);
    break;
  default:
    $banner["h1" = "Search results for ".htmlentities($parts[1],ENT_QUOTES,$config_charset);
    break;
}

Hope this helps!

Cheers,
David.