Example 18-3. 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.
{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.
{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.
<html>
<head>
<title>{$title|default:'Smarty News'}</title>
</head>
<body> |
footer.tpl