Smarty old and smarty new throws problem
  • PHP Fatal error:  Cannot redeclare smarty_function_escape_special_chars() (previously declared in /srv/www/htdocs/magyarszo4/www/include/smarty/plugins/shared.escape_special_chars.php:19) in /srv/www/htdocs/magyarszo4/www/library/smarty3/plugins/shared.escape_special_chars.php on line 27


    Why need two version of smarty? The problem sometimes come where use forms like search or poll.

    I have solved problem at this time with

    if(!function_exists('smarty_function_escape_special_chars'))
    {
    function smarty_function_escape_special_chars($string)
    {
        if(!is_array($string)) {
            $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
            $string = htmlspecialchars($string);
            $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
        }
        return $string;
    }
    }

    in files:
    library/smarty3/plugins/shared.escape_special_chars.php
    and
    include/smarty/plugins/shared.escape_special_chars.php

  • 4 Comments sorted by
  • hi, which newscoop version are u using?
  • Newscoop 4.0.3 and 4.0.4
  • ok. i think in general you can remove that one from include smarty (smarty2), this was used only for install as far as i know. (maybe just rename that folder). in 4.1 it will be removed
  • used in forms.
    {{ camp_edit }} not work if it removed :(