|
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 |
howsmarty Smarty n00b
Joined: 21 Jun 2019 Posts: 1
|
Posted: Fri Jun 21, 2019 8:06 am Post subject: Change template vars after creation |
|
|
I have a function that creates a template, assigns variables and returns the output.
I would like to change those variables in another php file, how can I do that ?
display_product.php :
Code: | <?php
function get_product_details_html(){
$tpl = $GLOBALS['tplEngine']->createTemplate('product_details_html.tpl');
$tpl->assign('product_detail_html_zone', 'some html code');
.....
}
} |
product_details.php :
Code: | <?php
$output = get_product_details_html();
$output .= hook_get_product_details_html();
echo $output; |
myPersonalModule.php :
Code: | <?php
function hook_get_product_details_html() {
[i]... here I would like to access to the current template and change some variables....[/i]
}
} |
|
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Fri Jun 21, 2019 8:45 am Post subject: |
|
|
I think the variables are always retrievable once assigned.
Code: | $currentTemplateVar = $tpl->getTemplateVars("product_detail_html_zone"); |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Jun 25, 2019 10:03 am Post subject: |
|
|
Your template call should be the last thing you do in your code.
There should be no "retrieve something from template" necessary. |
|
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
|