create multiple Smarty instances?

From: Date: Sun, 01 Sep 2002 16:30:09 +0000
Subject: create multiple Smarty instances?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5902@lists.php.net to get a copy of this message
I have several sub templates that are using same named tag for differnt values, and would like to include the results of the templates to my main template. What I came up with is to create mulitple Smarty instances and assign the results of the subtemplaets to the main template like this: // sub template 1 $smarty1= new Smarty(); $smarty1->assign('somevar', $somevar); // sub template 2 $smarty2 = new Smarty(); $smarty2->assign('somevar', $somevar); // main template $smarty = new Smarty(); $smarty->assign('results_of_sub_template1', $smarty1->fetch('subtemplate1.html')); $smarty->assign('results_of_sub_template2', $smarty2->fetch('subtemplate2.html')); $smarty->display('main_template.html'); I cannot use only one Smarty instance and do {include} here because sub templates are both using the same named tag (somevar) for different values. If I do that, the $somevar value assigned to subtemplate2.html will overwrite the value of $somevar that was supposed to be assigned to subtemplate1.html. What I would like to know is that if this would be much slower than just using one Smarty instance?

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