How to modify Smarty functions

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
piar
Forum Members
Forum Members
Posts: 10
Joined: Fri Feb 27, 2009 5:30 pm

How to modify Smarty functions

Post 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,
Last edited by piar on Thu Dec 16, 2010 9:41 pm, edited 1 time in total.
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm

Re: How to modify Smarty functions

Post by Jos »

You can use regular php functions as a Smarty modifier. What would you like it to do?
piar
Forum Members
Forum Members
Posts: 10
Joined: Fri Feb 27, 2009 5:30 pm

Re: How to modify Smarty functions

Post 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  ???
Last edited by piar on Thu Dec 16, 2010 10:25 pm, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: How to modify Smarty functions

Post by Wishbone »

http://forum.cmsmadesimple.org/index.ph ... 132.0.html

Try making your own modifier (renamed) and put it in the plugins directory.
Last edited by Wishbone on Thu Dec 16, 2010 10:44 pm, edited 1 time in total.
piar
Forum Members
Forum Members
Posts: 10
Joined: Fri Feb 27, 2009 5:30 pm

Re: How to modify Smarty functions

Post 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?
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: How to modify Smarty functions

Post by Wishbone »

Have you tried clearing the cache from the admin panel?
piar
Forum Members
Forum Members
Posts: 10
Joined: Fri Feb 27, 2009 5:30 pm

Re: How to modify Smarty functions

Post 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  ???
Post Reply

Return to “CMSMS Core”