View Single Post
  #19  
Old 09-04-2009, 09:39 AM
 
dwpers dwpers is offline
 

Senior Member
  
Join Date: Aug 2009
Location: Washington D.C.
Posts: 136
 

Default Re: Page Title in 4.2

Here is another possible solution:

Passing variable title to header template

When the majority of your templates use the same headers and footers, it is common to split those out into their own templates and {include} them. But what if the header needs to have a different title, depending on what page you are coming from? You can pass the title to the header as an attribute when it is included.

Passing the title variable to the header template
mainpage.tpl - When the main page is drawn, the title of ⌠Main Page■ is passed to the header.tpl, and will subsequently be used as the title.

Code:
{include file='header.tpl' title='Main Page'} {* template body goes here *} {include file='footer.tpl'}

archives.tpl - When the archives page is drawn, the title will be ⌠Archives■. Notice in the archive example, we are using a variable from the archives_page.conf file instead of a hard coded variable.

Code:
{config_load file='archive_page.conf'} {include file='header.tpl' title=#archivePageTitle#} {* template body goes here *} {include file='footer.tpl'}

header.tpl - Notice that ⌠Smarty News■ is printed if the $title variable is not set, using the default variable modifier.

Code:
<html> <head> <title>{$title|default:'Smarty News'}</title> </head> <body> footer.tpl </body> </html>


This is all information that can be found in the Smarty docs.
__________________
X-Cart Pro 4.2.2
Reply With Quote