I created a simple module who provide an {udt}.
Every parameters call of the {udt} are logged in $_SESSION['my_udt'][] = array();.
I used 'ContentPostRender' event's, to know when to stop logging {udt} calls.
Perfect ! I catch all calls ... but their order is 'weird'. The {udt}'s calls, who are stored in templates were logged at the end of my $_SESSION stack.
After some research i found that it was due to what explain Calguy here.
'process_whole_template', is supposed to be off, therefore, the template is processed this way:
a) the body
b) the head
If i set $config['process_whole_template'] to true, my issue is solved, the order of my {udt} calls are, in the intended order , semantic'.
Does anyone can help me to know if my {udt} is called from 'the head' or 'the body', so it would be easy to reorder my calls without setting process_whole_template to true.
I dig in this way, http://forum.cmsmadesimple.org/viewtopi ... =6&t=38543 but those events are still misteries to me and they don't even seem's to help me in this case
Tracking {udt} calls following HTML semantic order
Re: Tracking {udt} calls following HTML semantic order
Simple thought: check if the generated content contains "<head" ?Youpi wrote:Does anyone can help me to know if my {udt} is called from 'the head' or 'the body', so it would be easy to reorder my calls without setting process_whole_template to true.
Re: Tracking {udt} calls following HTML semantic order
@Jos: I'm not sure i can get current state of the generated content, only the entire state, with $gCms->variables['template']; But i don't know very well the CMS MS API. Perhaps there is another way to do that ?
Anyway, i found that $smarty->_plugins['function']['udt_name'][1], contains resource_name who can be filled with: tpl_head, tpl_body, tpl_top, etc ..
I displayed the whole of the $smarty->_plugins['function'], and i saw that all of my {udt} calls are detected as a part of the tpl_body even if they are inserted in the <head> part of a template, while for example {cms_stylesheet} is well declared as part of tpl_head.
If i take a look to tmp\templates_c\cahe_str_tpl_header_cahce_str_again.php i found:
smarty_core_load_plugins(array('plugins' => array(array('function', 'sitename', 'tpl_head:23', 2, false)); wich define, strictly, resource_name with 'tpl_head:23'
while later simply:
echo $this->_plugins['function']['my_udt'][0][0]->function_plugin(array('param1' => 'hello'), $this); who don't specify a resource_name and ( i think) fall by default in tpl_body.
A simple solution would be to add some event hooks, in index.php file of CMS MS, so modules/plugins could detecte when those differents part of a template are processed. Which mean modifying CMS MS :s
Anyone has a more realistic idea/solution ?
Anyway, i found that $smarty->_plugins['function']['udt_name'][1], contains resource_name who can be filled with: tpl_head, tpl_body, tpl_top, etc ..
I displayed the whole of the $smarty->_plugins['function'], and i saw that all of my {udt} calls are detected as a part of the tpl_body even if they are inserted in the <head> part of a template, while for example {cms_stylesheet} is well declared as part of tpl_head.
If i take a look to tmp\templates_c\cahe_str_tpl_header_cahce_str_again.php i found:
smarty_core_load_plugins(array('plugins' => array(array('function', 'sitename', 'tpl_head:23', 2, false)); wich define, strictly, resource_name with 'tpl_head:23'
while later simply:
echo $this->_plugins['function']['my_udt'][0][0]->function_plugin(array('param1' => 'hello'), $this); who don't specify a resource_name and ( i think) fall by default in tpl_body.
A simple solution would be to add some event hooks, in index.php file of CMS MS, so modules/plugins could detecte when those differents part of a template are processed. Which mean modifying CMS MS :s
Anyone has a more realistic idea/solution ?