Componentized Templates

From: Date: Thu, 18 Sep 2003 19:15:50 +0000
Subject: Componentized Templates
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10239@lists.php.net to get a copy of this message
Hi, I'm trying to use Smarty in a project, but I'm having some problems. The first one was about including templates dynamically, some of you helped me out but I wasn't able to see how your tips would fit in my problem. I'm starting to believe that the problem is with me. But thanks, anyway. Now I'm trying to use the Componentized Templates tip as shown in the documentation, but again I'm having some trouble. I have a simple template and a PHP file the holds its logic, and another. If I used them separatelly, they work fine, but using {include_php} tag is not working. The files are above: **************************************** This Works (URL: localhost/.../simple.php): <!-- simple.php --> <? define('SMARTY_DIR', '/usr/local/lib/php/Smarty-2.5.0/libs/'); require_once(SMARTY_DIR . "Smarty.class.php"); $smarty = new Smarty; $foo = array(1, 2, 3, 4); $smarty->assign("values", $foo); $smarty->display("simple.tpl"); ?> <!-- simple.tpl --> <table border=1> <tr> {section name=s_columns loop=$values} <td>{$values[s_columns]}</td> {/section} </tr> </table> *************************************************** This doesn't work (URL: localhost/.../main.php): <!-- simple.php --> <? define('SMARTY_DIR', '/usr/local/lib/php/Smarty-2.5.0/libs/'); require_once(SMARTY_DIR . "Smarty.class.php"); $smarty = new Smarty; $foo = array(1, 2, 3, 4); $smarty->assign("values", $foo); ?> <!-- simple.tpl --> {include_php file="simple.php"} <table border=1> <tr> {section name=s_columns loop=$values} <td>{$values[s_columns]}</td> {/section} </tr> </table> <!-- main.php --> <? $smarty = new Smarty; $smarty->display("simple.tpl"); ?> I apologise for the long mail, but making this work is crucial to the adoption of Smarty in our company. Thanks again, -- +---------------------------------------------------+ | Alvaro Nunes Melo Atua Sistemas de Informacao | | al_nunes@atua.com.br www.atua.com.br | | UIN - 42722678 (54) 327-1044 | +---------------------------------------------------+

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