Tracking {udt} calls following HTML semantic order

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Youpi
New Member
New Member
Posts: 7
Joined: Thu Jan 15, 2009 7:01 pm

Tracking {udt} calls following HTML semantic order

Post by Youpi »

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
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Tracking {udt} calls following HTML semantic order

Post by Jos »

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.
Simple thought: check if the generated content contains "<head" ?
Youpi
New Member
New Member
Posts: 7
Joined: Thu Jan 15, 2009 7:01 pm

Re: Tracking {udt} calls following HTML semantic order

Post by Youpi »

@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 ?
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Tracking {udt} calls following HTML semantic order

Post by applejack »

Post Reply

Return to “Developers Discussion”