Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

传递标题到头部模板

当你的模板多数使用了相同的头部和底部HTML代码,通常 会将它们分隔到单独的模板中,用 {include}来载入它们。 但如果头部HTML会根据页面的不同,而需要有不同的标题, 那么你需要在包含模板时设置标题为属性

Example 21.3. 传递标题到头部模板

mainpage.tpl - 当主体页面被渲染时, Main Page的标题值会被传递到 header.tpl,这样就可以被当作标题使用了。


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

    

archives.tpl - 当主体页面被渲染时, 页面标题会是Archives。 注意在下面例子中,我们使用了来自配置文件archives_page.conf的变量,替代硬编码的变量值。


{config_load file='archive_page.conf'}

{include file='header.tpl' title=#archivePageTitle#}
{* template body goes here *}
{include file='footer.tpl'}

    

header.tpl - 注意下面例子使用了 default的变量修饰器,当标题$title 变量未设置时,将显示Smarty News


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

    

footer.tpl


</body>
</html>

    

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 5 plus 20? (Are you human?)

Advertisement