PDA

View Full Version : Help with Smarty



jteerman
01-14-10, 01:27 PM
I'd like to modify my header.tpl file to modify the <title> and <meta description> tags based on the page they are accessing. I've added this to my file:

{php}
if ( $_SERVER["PHP_SELF"] = "/index.php" ) {
$metatitle = "Home Page ";
$metadescription = "This is the HOME meta description. ";
}
if ( $_SERVER["PHP_SELF"] = "/hosting.php" ) {
$metatitle = "Hosting Plans Page";
$metadescription = "This is the HOMSTING PLANS meta description. ";
}
{/php}
<title>{$companyname} - {$metatitle}</title>

When the page displays, only the company name appears.

Any help will be greatly appreciated!

Jeff

m00
01-14-10, 01:35 PM
You can request them inside in a new PHP-tag:


{php}
if ( $_SERVER["PHP_SELF"] == "/index.php" ) {
$metatitle = "Home Page ";
$metadescription = "This is the HOME meta description. ";
}
if ( $_SERVER["PHP_SELF"] == "/hosting.php" ) {
$metatitle = "Hosting Plans Page";
$metadescription = "This is the HOMSTING PLANS meta description. ";
}
{/php}
<title>{$companyname} - {php}echo $metatitle;{/php}</title>

sparky
01-14-10, 01:37 PM
{if $filename=="index"}
{assign var="metatitle" value="Home Page "}
{assign var="metadescription" value="This is the HOME meta description. "}
{elseif $filename=="hosting"}
{assign var="metatitle" value="Hosting Plans Page"}
{assign var="metadescription" value="This is the HOMSTING PLANS meta description. "}
{/if}

<title>{$companyname} - {$metatitle}</title>
<meta name="description" content="{$metadescription}">

jteerman
01-14-10, 01:58 PM
{if $filename=="index"}
{assign var="metatitle" value="Home Page "}
{assign var="metadescription" value="This is the HOME meta description. "}
{elseif $filename=="hosting"}
{assign var="metatitle" value="Hosting Plans Page"}
{assign var="metadescription" value="This is the HOMSTING PLANS meta description. "}
{/if}

<title>{$companyname} - {$metatitle}</title>
<meta name="description" content="{$metadescription}">


Thanks Sparky!

Jeff