Re: [SMARTY] Question on componentized templates

From: Date: Mon, 08 Jan 2007 13:36:53 +0000
Subject: Re: [SMARTY] Question on componentized templates
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13664@lists.php.net to get a copy of this message
Robert Hazeltine wrote: > Hi > > I'm new to the use of Smarty templates so I hope someone can assist with > my question. Is it possible to substitute a variable in in following > example - ie symbol = $smarty. Is there some reason, I cannot do this > but, if I can, how? > > Example: > > $smarty = "YAHOO"; > > {load_ticker symbol='SMARTY' assign='ticker'} > {load_ticker symbol='{$smarty}' assign = 'ticker'} in your php file: // $smarty is a Smarty object $smarty->assign('TickerSymbol', 'YAHOO'); in your template: {load_ticker symbol=$TickerSymbol assign='ticker'} I would strongly suggest never using a variable named $smarty purely because Smarty uses that name internally all over the place to point to the/a Smarty object; with the exception of using $marty to point to your Smarty object :-) > > Alternatively is there another way you can suggest to use a template > function to read the data in a similar manner. the function that maps to the load_ticker plugin name can pretty much do anything it wants in terms of grabbing data (db connections, using constants, using a application config source) - basically anything you care to imagine. > > > Rob... > Robert Hazeltine Phone: +61(2) 9678-7621 > Senior Analyst/Programmer Mobile: 0410311656 > University of Western Sydney Email: r.hazeltine@uws.edu.au >

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