Jump to content

[Solved] Smarty3 Escape Not Working With Blocklayered Json


yaniv14

Recommended Posts

I am using Prestashop 1.6.1.4 and all seem to be working fine except escaping json returned data from ajax call.

Using blocklayered navigation giving error 500 when trying to render/escape json data from server to product-list.tpl.

Regular pages which use the same file (product-list.tpl) working just fine.

The error I am getting is:

Undefined index: escape in/home/xxx/public_html/cache/smarty/compile/e4/a1/fd/e4a1fd2f5285aae65055ce86ad9af69b31b94166.file.product-list.tpl.php on line 95

Fatal error: Call to a member function escape() on a non-object in/home/xxx/public_html/cache/smarty/compile/e4/a1/fd/e4a1fd2f5285aae65055ce86ad9af69b31b94166.file.product-list.tpl.php on line 95

This is a brand new server and at the beginning I had also an issue when trying to truncate chars so I had to install mbstring thru EasyApache 3 and everything was fixed.

My guess is that I am missing some mod/extension/plugin for Apache or PHP.

Any help will be apreciated.

Edited by yaniv14 (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...

I am still struggling with this module on different sever and it seems that it has some issues with smarty cache.

Try to disable Smart cache in BO and clear all cache and check if its working for you.

 

For now I disabled the smarty cache to get this module working but it slows down the page loading time because the templates are not cached. 

Link to comment
Share on other sites

  • 2 weeks later...

Hello, i have same issue too, i dont understand what do to, help me pls. 

I google this: http://stackoverflow.com/questions/34916901/smarty3-escape-not-working-with-json/34934014

But i dont have apache on my server, nginx+php-fpm....

 

 

[20-Feb-2016 15:48:14 Europe/Moscow] PHP Notice:  Undefined index: escape in /var/www/www/data/www/dev.wwwwear.com/cache/smarty/compile/2a/75/b0/2a75b02d6db6ad53f61cd17d971a0547e0319100.file.product-list.tpl.php on line 92
[20-Feb-2016 15:48:14 Europe/Moscow] PHP Fatal error:  Call to a member function escape() on a non-object in /var/www/www/data/www/dev.wwwwear.com/cache/smarty/compile/2a/75/b0/2a75b02d6db6ad53f61cd17d971a0547e0319100.file.product-list.tpl.php on line 92
 
PS.: I have two site on this server, one on 1.6.0.14 (where is problem) and one one 1.6.1.4....on newest version no problem...
 
Edited by Kerm (see edit history)
Link to comment
Share on other sites

Ok i think is done, i change on this:

 

    public function __construct($name = null, $context = null)
    {
        $this->errors      = array();
        $this->warnings    = array();
        $this->params_back = array();
        $this->globals     = new stdClass();
        $this->fillGlobalVars();

        parent::__construct($name, $context);

        $file_smarty_config = _PS_ROOT_DIR_.'/config/smarty.config.inc.php';
        if (is_file($file_smarty_config)) {
            if (is_writable($file_smarty_config)) {
                $content = Tools::file_get_contents($file_smarty_config);

                if (!strstr($content, 'escapePTS')) {
                    $content .= '
                        //CODE MODULES PRESTEAMSHOP - PLEASE NOT REMOVE
                        //--------------------------------------------------------------------------------------------------------
                        smartyRegisterFunction($smarty, "modifier", "escape", "escapePTS");
                        function escapePTS($string, $esc_type = "html", $char_set = null, $double_encode = true, $as_html = false)
                        {
                            $smarty_escape = SMARTY_PLUGINS_DIR."modifier.escape.php";
                            include_once $smarty_escape;

                            if (!$as_html && is_callable("smarty_modifier_escape")) {
                                $string = call_user_func("smarty_modifier_escape", $string, $esc_type, $char_set, $double_encode);
                            } else {
                                $string = html_entity_decode($string);
                            }

                            return $string;
                        }
                        //--------------------------------------------------------------------------------------------------------
                    ';
                    file_put_contents($file_smarty_config, $content);
                }
            }
        }

        $this->smarty = $this->context->smarty;
        $this->cookie = $this->context->cookie;

        $this->fillConfigVars();
    }

And remove escape function at end of file....

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...

Ok i think is done, i change on this:

 

 

    public function __construct($name = null, $context = null)
    {
        $this->errors      = array();
        $this->warnings    = array();
        $this->params_back = array();
        $this->globals     = new stdClass();
        $this->fillGlobalVars();

        parent::__construct($name, $context);

        $file_smarty_config = _PS_ROOT_DIR_.'/config/smarty.config.inc.php';
        if (is_file($file_smarty_config)) {
            if (is_writable($file_smarty_config)) {
                $content = Tools::file_get_contents($file_smarty_config);

                if (!strstr($content, 'escapePTS')) {
                    $content .= '
                        //CODE MODULES PRESTEAMSHOP - PLEASE NOT REMOVE
                        //--------------------------------------------------------------------------------------------------------
                        smartyRegisterFunction($smarty, "modifier", "escape", "escapePTS");
                        function escapePTS($string, $esc_type = "html", $char_set = null, $double_encode = true, $as_html = false)
                        {
                            $smarty_escape = SMARTY_PLUGINS_DIR."modifier.escape.php";
                            include_once $smarty_escape;

                            if (!$as_html && is_callable("smarty_modifier_escape")) {
                                $string = call_user_func("smarty_modifier_escape", $string, $esc_type, $char_set, $double_encode);
                            } else {
                                $string = html_entity_decode($string);
                            }

                            return $string;
                        }
                        //--------------------------------------------------------------------------------------------------------
                    ';
                    file_put_contents($file_smarty_config, $content);
                }
            }
        }

        $this->smarty = $this->context->smarty;
        $this->cookie = $this->context->cookie;

        $this->fillConfigVars();
    }

And remove escape function at end of file....

 

 

Thanks it's working for me. I'm on Prestashop 1.6.1.1 with onepagecheckoutps v2.1.4. I was having errors in admin, when using the search function, received error 500:

Undefined index: escape in cache/smarty/compile/c9/c5/9d/c9c59dbc5a2d699170b6a31908f00d90b430ac61.file.blockcart.tpl.php on line 70

It only worked if I cleared the cache. But now I don't see these errors anymore. Thanks! :)

Edited by zanpo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...