Re: [SMARTY] Re: Variables in variables

From: Date: Wed, 06 Nov 2002 14:01:23 +0000
Subject: Re: [SMARTY] Re: Variables in variables
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6331@lists.php.net to get a copy of this message
Sorry, but this way is not the one, I can do, because I can't insert data like that. Try the following: index.php <? $smarty = new Smarty; $smarty->assing("Shop_Name", "Test Shop"); $smarty->assign("Shop_FrontPage", "You are now in: {$Shop_Name}."); $smarty->display("index.tpl"); ?> index.tpl <html> <head><title>{$Shop_Name}</title></head> <body> Name: {$Shop_Name}<br> FrontPage: {$Shop_FrontPage}<br> </body> </html> And this is the output: Name: Test Shop FrontPage: You are now in: . The point is, that both Name and Frontpage are dynamically loaded from a db and I don't want to parse the FrontPage on my own to insert the variables, because they are already published in smarty. Any other ideas??? "K" <szkaroly@freemail.hu> schrieb im Newsbeitrag news:20021104175634.4f6d89d3.szkaroly@freemail.hu... > > ... whereby $shop->data is an associative array that contains all my > > shop-data :). In $shop->data I have $shop->data["Shop_Name"] and > > $shop->data["Shop_FrontPage"]. Now the example, how I would think > > smarty should work, but doesnt. > ... > > So if my data would be the following (pseudo code): > > Shop_Name = Test Shop > > Shop_FrontPage = Welcome to {$Shop_Name},<br> nice to meet you. > > I would expect that the {$Shop_Name} variable would be replaced by > > Test Shop, but instead it is left blank. The title is displayed > > correctly, so there is no problem with the variables. > > Maybe use this: > > Shop_FrontPage = "Welcome to ".$shop->data["Shop_Name"].", nice to > meet You."; > > Don't mix up PHP ("logic") with Smarty (html creation). > > k >

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