Re: [SMARTY] Is it possible to retrieve a value from a template

From: Date: Sat, 08 Feb 2003 05:58:32 +0000
Subject: Re: [SMARTY] Is it possible to retrieve a value from a template
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7583@lists.php.net to get a copy of this message
Hi, I think i understand the concepts of templates (i hope ;)), but in my pages, i have a lot of blocs wich can be shown or not by the user... If I must execute all sql requests to use only 1, i think it's stupid ;)) then thats the reason I want to know if I must execute a sql before do it ;) for example if the user dont want to see the news bloc, I think its stupid to extract them ;)) Thnx Laurent ----- Original Message ----- From: "Jason Jones" <jason@tekscode.com> To: "LPA" <lpasseb@numericable.fr> Cc: <smarty-general@lists.php.net> Sent: Saturday, February 08, 2003 6:45 AM Subject: Re: [SMARTY] Is it possible to retrieve a value from a template > I think you're missing the whole beauty of the Smarty system. Smarty > provides a clean abstraction between your PHP code and a display > mechanism... in other words... let PHP do all the grunt work in > preparing the data (and getting info/data from an SQL DB), assign all > the relevant variables to the Smarty template, and then show the > template... something like this, for example: > > script.php: > > $count = $DB->getOne("select foo from bar"); > > $smarty = new Smarty; > $smarty->assign("count", $count); > $smarty->display("thing.tpl"); > > > thing.tpl > > <html><body>The count was {$count}</body></html> > > Maybe that's not what you were getting at. But besides that, the > templates can be programmed with conditional logic to display the > correct block and utilize the appropriate variables. HTH... > > -Jason Jones >

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