Get Smarty

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:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

Variablen an eingebundene Templates weitergeben

Wenn die Mehrzahl Ihrer Templates den gleichen Header und Footer verwenden, lagert man diese meist in eigene Templates aus und bindet diese mit{include} ein. Was geschieht aber wenn der Header einen seitenspezifischen Titel haben soll? Smarty bietet die Möglichkeit, dem eingebundenen Template, Variablen als Attribute zu übergeben.

Example 18.3. Die Titel-Variable dem Header-Template zuweisen

mainpage.tpl - Beim Aufbau der Hauptseite wird der Titel "Hauptseite" an header.tpl übergeben und dort verwendet.


{include file="header.tpl" title="Hauptseite"}
{* template body hier *}
{include file="footer.tpl"}

    

archives.tpl



{config_load file="archiv.conf"}
{include file="header.tpl" title=#archivSeiteTitel#}
{* template body hier *}
{include file="footer.tpl"}

    

header.tpl - Zur Info: wenn kein $titel übergeben wurde wird hier mittels des default-Modifikator der Titel "Nachrichten" verwendet.


<html>
<head>
<title>{$title|default:"Nachrichten"}</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 16 plus 0? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk