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

Passage du titre à un template d'en-tête

Quand la majorité de vos templates utilisent les mêmes en-tête et pied-de-page, il est d'usage de les mettre dans leurs propres templates et de les inclure ({include}). Mais comment faire si l'en-tête doit avoir un titre différent, selon la page d'où on vient ? Vous pouvez passer le titre à l'en-tête en tant qu' attribut quand il est inclus.

Example 18.3. Passer le titre au template d'en-tête

mainpage.tpl - Lorsque la page principal est construite, le titre Man Page est passé au header.tpl et sera utilisé en tant que titre.


{include file='header.tpl' title='Main Page'}
{* le corps du template va ici *}
{include file='footer.tpl'}

   

archives.tpl - Lorsque la page principal est construite, le titre sera Archives. Notez que dans cet exemple, nous utilisons une variable du fichier archives_page.conf au lieu d'une variable classique.


{config_load file='archive_page.conf'}

{include file='header.tpl' title=#archivePageTitle#}
{* corps du template ici *}
{include file='footer.tpl'}

   

header.tpl - Notez que Smarty News est affiché si la variable $title n'est pas définie, en utilisant le modificateur de variable par default.


<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 6 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