Search code examples
prestashopprestashop-1.7prestashop-modules

PrestaShop Call to undefined method FrontController::parseCMSContent() after update to 1.7.8.2


I created some custom shortcodes for my PrestaShop by creating a file (override/classes/controller/FrontController.php) with a method like :

public static function parseCMSContent($content)
{
...
}

And in my module and cms smarty templates I changed:

{$cms.content nofilter}

to:

{FrontController::parseCMSContent($cms.content) nofilter}

Everything was working fine with Prestashop 1.7.7.5, but the update to 1.7.8.2 broke the whole thing.

I get a 500 error saying :

PHP Fatal error: Uncaught Error: Call to undefined method FrontController::parseCMSContent() ... .module.pscustomtextpscustomtext. ...

It's still working fine with debug mode enabled though..

I can't find anything about the function being deprecated, any idea on how I could get this working again please?


Solution

  • In case this can help anyone, I fixed this by moving my override into a new smarty plugin.

    I created a file vendor/smarty/smarty/libs/plugins/function.get_shortcoded_content.php

    I added my shortcodes in:

    function smarty_function_get_shortcoded_content($params, &$smarty)
    {
    ...
    }
    

    And in my smarty files I called:

    {get_shortcoded_content content=$cms.content}
    

    instead of:

    {$cms.content nofilter}
    

    It seems to work all fine again.