mautic-advanced-templates-bundle icon indicating copy to clipboard operation
mautic-advanced-templates-bundle copied to clipboard

Reusable code snippets - Error

Open soyniqolas opened this issue 4 years ago • 2 comments

Hi ! I'm trying to use a reusable code snippet creating a Dynamic Content and including it on my email using the next code:

{% TWIG_BLOCK %} {{ include('dc:featured-products') }} {% END_TWIG_BLOCK %}

In the Dynamic Content I declare some variables using {% set products = items.products %}, but It returns me a 500 Error.

On the Mautic error log I got this message: [2020-03-09 12:36:09] mautic.CRITICAL: Uncaught PHP Exception Twig_Error_Syntax: "Unexpected token "operator" of value "%" in "dc:featured-products" at line 3." at /vendor/twig/twig/lib/Twig/ExpressionParser.php line 208 {"exception":"[object] (Twig_Error_Syntax(code: 0): Unexpected token \"operator\" of value \"%\" in \"dc:featured-products\" at line 3. at /vendor/twig/twig/lib/Twig/ExpressionParser.php:208)"} []

Does the 'include' TWIG function support variable declaration or anything that starts with {% ? In the example of this plugin there is only variable printing with {{ }}.

soyniqolas avatar Mar 09 '20 15:03 soyniqolas

I have a similar issue. I've successfully used techniques from Example 1 & 2. I was unable to replicate working Example 3, despite closely following the documentation. If not for the cart functionality, I was hoping it could be a workaround Matutics lack of globally updatable variables.

It seems this feature doesn't work anymore. At least not on Mautic 2.16.2 & PHP 7.3.18.

szczepkacpra avatar Jun 13 '20 12:06 szczepkacpra

I can confirm: inserting a Dynamic Web Content in emails works in Mautic 4.4.8 .

I had some errors, but something else has caused them.

IonutOjicaDE avatar Jun 09 '23 21:06 IonutOjicaDE