Mercurial > defr > templates
view blog.php @ 17:d4ac7cef0cdd
Recherche du fichier de template dans le path.
Cela permet de définir proprement un include_path en début de script,
et de ne préciser que le nom du fichier template en paramètre du
constructeur.
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Wed, 24 Oct 2007 20:49:32 +0200 |
parents | 673d9845fc16 |
children |
line wrap: on
line source
<?php require_once('class.template.php'); $tpl = new Template('blog_index.xml'); $p1 = new Template('blog_post.xml'); $p1->setParams(array( '#post@class' => 'PostContent Weird', 'postTitle' => 'Lorem ipsum', 'postDate' => 'lundi 19 mars 2007, 00h37', '#mood@src' => '/blog/mood/Weird.png', '#mood@alt' => 'Mood: Weird', 'postContent' => 'Lorem ipsum sit dolor amet', 'postTags' => 'Voyage, Toulon, SNCF', 'postNumber' => '#0002', 'postComments'=> 'Un petit commentaire ?' )); $p2 = new Template('blog_post.xml'); $p2->setParams(array( '#post@class' => 'PostContent Cool', 'postTitle' => 'Sit dolor', 'postDate' => 'samedi 17 mars 2007, 00h37', '#mood@src' => '/blog/mood/Cool.png', '#mood@alt' => 'Mood: Cool', 'postContent' => 'sit dolor amet', 'postTags' => 'Voyage, Toulon, SNCF', 'postNumber' => '#0001', 'postComments'=> 'Un petit commentaire ?' )); $params = array( 'title' => 'Dual Blog', 'head' => array( array( 'link@rel' => 'StyleSheet', 'link@href' => '/css/truc.css', 'link@title' => 'Truc' ), array( 'link@rel' => 'Alternate StyleSheet', 'link@href' => '/css/chose.css', 'link@title' => 'Chose' ) ), '#Posts' => array( array('post' => $p1), array('post' => $p2) ) ); $tpl->setParams($params); echo $tpl; ?>