Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Change template vars after creation

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
howsmarty
Smarty n00b


Joined: 21 Jun 2019
Posts: 1

PostPosted: Fri Jun 21, 2019 8:06 am    Post subject: Change template vars after creation Reply with quote

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Jun 21, 2019 8:45 am    Post subject: Reply with quote

I think the variables are always retrievable once assigned.
Code:
$currentTemplateVar = $tpl->getTemplateVars("product_detail_html_zone");
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Jun 25, 2019 10:03 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP