Dynamically changing a Smarty variable via. PHP? -
i have outer template in smarty (the background template), displays versioning number of section of project in footer.
the variable in question, {$noversion}, string parameter returned web-service response. have 2 seperate web-service calls, each 1 being different section of project , containing different string parameter. change versioning string in footer depending on section of project on.
i can assign 1 of these using php when page loads, i'm finding impossible modify template dynamically after click/load of separate page has occurred..
so, how can dynamically modify smarty variable in defined template inside php?
my code below.
zone.tpl:
<div> <p>the version - {$noversion}</p> </div> php:
$wsname = $this->namews; // returns string - either 'reporting' or 'other' depending on section of website has been selected. if($wsname == "reporting"){ // reporting 1 of 2 sections $tplcontent = new copixtpl(); // template content $modevadmin = new boxmodule('evadmin'); // new module boxwebservices::create($wsname); // start web service dependant on section $retourdtod = boxwebservices::call($wsname.'|getversion'); // string parameter $tplcontent->assign('noversion', (is_string($retourdtod)) ? $retourdtod : '?'); // supposed assign string parameter {$noversion} smarty variable in zone.tpl. } am missing something? seem returning strings , everything, last line not update smarty variable on page in front of me. have signify specific template file in there somewhere?
here's var_dumps of above:
$wsname var_dump = string(9) "reporting"
$tplcontent var_dump before assignment =
object(copixtpl)#350 (2) { ["_vars"]=> array(0) { } ["templatefile"]=> null } $retourdtod var_dump = string(14) "1.0.8"
$tplcontent var_dump after assignment (last line of code above) =
object(copixtpl)#350 (2) { ["_vars"]=> array(1) { ["evanoversion"]=> string(14) "1.0.8" } ["templatefile"]=> null } if above confusing, this:
if section: 1. string variable webservice. 2. particular template file. 3. overwrite current smarty variable value in template new string variable.
your $tplcontent object presumably represents template, or variables prepare 1 (it doesn't appear descended smarty object), in code you've pasted show render template html.
just creating new object of right type won't change existing rendering code - need make assignment on object used display page.
Comments
Post a Comment