Page 1 of 1

How to modify Smarty functions

Posted: Thu Dec 16, 2010 9:38 pm
by piar
Hi All!

I would like to change a bit behaviour of one Smarty function (ie. it is smarty_modifier_escape in  cmsms/lib/smarty/plugins/modifier.escape.php).

However modifying this source file does not seem to have any effect on web page. I've even added there some 'echo' instructions for debug purpose but I do not see output of these echos.

Last thing I've done was changing name of this file to: modifier.escape.php.old that also does not make any effect - escapes in templates still works fine ???

Does it mean that my cmsms is using Smarty from host instead of this one that is in cmsms/lib/smarty directory?

What should I do to change this modifier implementation?

Regards,

Re: How to modify Smarty functions

Posted: Thu Dec 16, 2010 9:50 pm
by Jos
You can use regular php functions as a Smarty modifier. What would you like it to do?

Re: How to modify Smarty functions

Posted: Thu Dec 16, 2010 9:59 pm
by piar
My purpose is to change template modifier:

Code: Select all

|cms_escape:htmlall
to behave like:

Code: Select all

|cms_escape:html
This is very simple change in file I've mentioned. The original code is:

Code: Select all

function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1')
{
    switch ($esc_type) {
        case 'html':
            return htmlspecialchars($string, ENT_QUOTES, $char_set);

        case 'htmlall':
            return htmlentities($string, ENT_QUOTES, $char_set); 
...
and my mod:

Code: Select all

function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1')
{
    switch ($esc_type) {
      case 'html':
      case 'htmlall':
            return htmlspecialchars($string, ENT_QUOTES, $char_set);
...
This is trivial. But why I don't see effects on my page - still escape:htmlall works different then escape:html  ???

Re: How to modify Smarty functions

Posted: Thu Dec 16, 2010 10:33 pm
by Wishbone
http://forum.cmsmadesimple.org/index.ph ... 132.0.html

Try making your own modifier (renamed) and put it in the plugins directory.

Re: How to modify Smarty functions

Posted: Thu Dec 16, 2010 10:47 pm
by piar
Wishbone - this is not that case. I do not have any question of how to make escape:htmlall works as escape:html - this is my modification.

My question is rather to use of Smarty in cmsms. Is cmsms always using Smarty that comes with it or in some situation it uses Smarty provided by target host where the cmsms is installed? If so - can I force cmsms to use Smarty that comes with it?

Or maybe modifiers are somehow cached and that cache can be removed?

Re: How to modify Smarty functions

Posted: Thu Dec 16, 2010 10:47 pm
by Wishbone
Have you tried clearing the cache from the admin panel?

Re: How to modify Smarty functions

Posted: Thu Dec 16, 2010 10:55 pm
by piar
Wishbone wrote: Have you tried clearing the cache from the admin panel?
Yes I have - as well as directly clearing templates_c - but this didn't help.

This is really strange that I can even remove file with escape modifier implementation and this modifier still works in templates  ???