Re: [SMARTY] Newbee Question about how smarty works

From: Date: Mon, 10 Nov 2003 16:10:17 +0000
Subject: Re: [SMARTY] Newbee Question about how smarty works
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10515@lists.php.net to get a copy of this message
Mark Dyer wrote:
Inside my template I would like to show different templates depending on if they have logged into the site or not.
Do I check if the user is logged in from my index.php file than call the related template ie loginbox or user logged in links and save this output to a var.
I would recommend validating if the user has logged on properly in your PHP script. You can do something like this in your template: {include file=$includeTemplate} In your PHP script, do something like this: --- code --- if (userlogged()) {
    $includeTemplate = 'yahoo.tpl';
} else {
    $includeTemplate = 'login.tpl';
} $smarty->assign('includeTemplate', $includeTemplate); --- code --- This will dynamically include either yahoo.tpl or login.tpl. But be careful not to do too much inside the smarty, templates are for output, not for program logic. Personally, I wouldn't put all forms etc. directly into a template, although of course it makes sense to use the smarty form functions and let smarty handle the output. Still, I can definitely encourage you to use smarty, it makes programming life so much easier. regards martin -- Shall we hit it and quit? Yeah, hit it and quit? OK? Hit it!

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