Jump to content

Help with Smarty


jteerman

Recommended Posts

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

Link to comment
Share on other sites

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>

Edited by m00
Link to comment
Share on other sites

{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}">

Link to comment
Share on other sites

{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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated