Script Evaluation Limitations

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Script Evaluation Limitations

Post by cmb » Fri Apr 27, 2012 4:33 pm

Hello Developers,

since CMSimple_XH 1.5 the evaluation routine of CMSimple scripting and the plugin call is encapsulated as function as it's now being used from several places (content, search, newsbox). This way it can even be used by plugins. The first draft kept $output as a local variable. This stopped Klaus' Treichlers highslide plugin from working as it writes to global $output directly instead of returning it's output as usual (this technique might be used in other plugins too). So I suggested to introduce $output as global variable in evaluate_cmsimple_scripting(). Later there were found issues with this approach so I added $output='' at the end of the evaluation to reset $output.

Yesterday Albert reported, that the following does not work, if News01 is hidden by #CMSimple hide#:

Code: Select all

#CMSimple $output.=newsbox('News01');#
The result is, that only the content of the Newsbox is show on the page. The reason is quite obvious: when newsbox() calls evaluate_cmsimple_scripting() the old $output is reset '', so it is effectively discarded. In this case it's a viable workaround to hide the Newsbox by setting "show in menu" to "no" in page_params. But I expect similar problems with plugins that allow script evaluation, e.g. acDIVs, if they are called with #CMSimple $output.=...;# and if they evaluate something like #CMSimple $output.=...;#. This could be circumvented by using the plugin call {{{PLUGIN:...}}} instead, but to avoid any unexpected behavior, i suggest to change evaluate_cmsimple_scripting(). As I see now, resetting $output to '' is simply wrong. Instead it has to be reset to the value it had, when evaluate_cmsimple_scripting() was called. So at the beginning of this function:

Code: Select all

$__old_output = $output; 
should be added, and at the end:

Code: Select all

// $output = '';
$output = $__old_output; 
This way the newsbox example is working fine. I've made only some quick additional tests with the modified evaluate_cmsimple_scripting(), but everything seems to be ok.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply