Re: [SMARTY] "Smart" nesting of templates

From: Date: Mon, 10 Jun 2002 13:59:54 +0000
Subject: Re: [SMARTY] "Smart" nesting of templates
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4728@lists.php.net to get a copy of this message
Hi, first of all, I'm new to smarty. I've found it last week while searching for fast templating engine for my CMS. 24hdev@chaoscontent.com wrote:
Hi there, I am standing in front of a serious design problem and would appreciate some ideas. --exposition-- Imagine having some different PHP classes representing different types of data - an article class, a comment class and an image class. I have a smarty template for each class: article.tpl, comment.tpl, image.tpl. These templates need to be nested in their parent templates, e/g header.tpl on top and footer.tpl on the bottom - this is achieved using the smarty {include} function.
cool, we both are working on the same using the same methods ...
--problem-- Now my problem is that I want to be able to display data in two ways: - display one class per page (i/e just ONE article) - sequentially display many different classes at once on the same page (i/e article on top, image somewhere, comments below). If I do the latter, the header.tpl and footer.tpl are included every time I use a new template, since the {include} function is present in all of my sub-templates.
I've chosen different way - I can have nested objects - each renders itself, remembers the result of rendering and passes it to his "parent". Of course ech object can have his own template and parent doesn't know what he contains, he is calling his childs' render method and gets the result of chosen type (XML, TXT, HTML ...), which can be passed to parents' template as a variable content. - This all means I have one instance of smarty runnig for every instance of object. It may sound like overhead danger, but I'm rendering only once, the whole result is stored in structure of static page fragments handled by SSI. I believe, it's clear enough to u :o) -- -- Mirek Novak Anima Publishers CMS development http://www.auto.cz http://www.formule1.cz jabber:mirek@njs.netlab.cz ISEEKYOU:1<one>9<four>9<nine>44<eight> GEsEm:+420603807838

« previous php.smarty.general (#4728) next »