Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Assign by referrence sometimes makes life easier

 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 420
Location: Kathmandu, Nepal

PostPosted: Wed Apr 18, 2012 8:35 am    Post subject: Assign by referrence sometimes makes life easier Reply with quote

Take an example:

Code:
$page_details = array(
  // Data loaded somewhere from the database
  'template_file' => 'admin.php',
  ...
);

$smarty->assign('page', $page_details);

...

//******************/
// Now you decide to change the template file
// with some extra calculations, conditions, ...
if($member==4)
{
  $page_detais['template_file'] = 'admin-customized.php';
}
//******************/


...
// Your regular script
$smarty->display($page['template_file']);


For $member=4, the new template file is loaded.
It works good.

Even after a template was assigned earlier, you can change it later on before displaying the contents.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP