|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jovenshadow11 Smarty Rookie
Joined: 28 Jun 2011 Posts: 14
|
Posted: Thu Jul 14, 2011 1:17 pm Post subject: assign value using assign(); |
|
|
i have a template that has {$content} the data that i will put in the {$content} will be pulled out from the database
$dataFromDBase = "this is a sample datafrom DBase and another {$newVariable}";
$smarty->assign('content',$dataFromDBase);
Knowing that i used "{$newVariable}" in my content, now i want to assign value to this variable so i add this
$smarty->assign('newVariable',"new data for newVariable");
but when i will display this is what show on the browser
this is a sample datafrom DBase and another {$newVariable}
why the new data for {$newVariable} is not showing/ and its literally shows {$newVariable} ???
what is the right way to assign a value to a variable i put in my content? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
jovenshadow11 Smarty Rookie
Joined: 28 Jun 2011 Posts: 14
|
Posted: Thu Jul 14, 2011 1:44 pm Post subject: |
|
|
Thank you very much mohrt!
this is the new code and it works..
$smarty->assign('newTitle',"this is a test");
$var = $smarty->fetch("string:".$content->getContent()); // $content->getContent() is my class for getting the content in the database.
$smarty->assign('content',$var);
again thank you for your help! |
|
Back to top |
|
|
|
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
|