{"id":26878850,"url":"https://github.com/logicify/mautic-advanced-templates-bundle","last_synced_at":"2026-03-01T17:36:41.711Z","repository":{"id":43788871,"uuid":"156523126","full_name":"Logicify/mautic-advanced-templates-bundle","owner":"Logicify","description":"Plugin extends default email template capabilities with TWIG block so you can use advanced scripting techniques like conditions, loops etc","archived":false,"fork":false,"pushed_at":"2024-07-01T11:50:46.000Z","size":44,"stargazers_count":98,"open_issues_count":18,"forks_count":57,"subscribers_count":18,"default_branch":"master","last_synced_at":"2026-01-14T14:42:35.117Z","etag":null,"topics":["marketing","marketing-automation","mautic","twig"],"latest_commit_sha":null,"homepage":"https://logicify.com/?utm_source=github\u0026utm_campaign=mautic-templates\u0026utm_medium=opensource","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Logicify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-07T09:37:18.000Z","updated_at":"2025-12-25T16:02:35.000Z","dependencies_parsed_at":"2024-11-12T19:41:24.930Z","dependency_job_id":null,"html_url":"https://github.com/Logicify/mautic-advanced-templates-bundle","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Logicify/mautic-advanced-templates-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Logicify%2Fmautic-advanced-templates-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Logicify%2Fmautic-advanced-templates-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Logicify%2Fmautic-advanced-templates-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Logicify%2Fmautic-advanced-templates-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Logicify","download_url":"https://codeload.github.com/Logicify/mautic-advanced-templates-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Logicify%2Fmautic-advanced-templates-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29976288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["marketing","marketing-automation","mautic","twig"],"created_at":"2025-03-31T12:29:50.852Z","updated_at":"2026-03-01T17:36:41.689Z","avatar_url":"https://github.com/Logicify.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mautic Advanced Templates Bundle\n\nPlugin extends default email template capabilities with TWIG block so you can use advanced templating techniques like conditions, loops etc. Support has also been extended to sms templates.\n\n### Purpose\n\nFor example, you need a slightly different content of your email depending on the information you already know about your contact (e.g., country, gender, whatever). Instead of creating tons of very similar emails, you can create one with conditions coded inside.\n\nAnother example: you might want to include dynamic content to your email. Let's say you are implementing an Abandoned Cart feature and you want your customers to see exact content of their cart. Again, the solution might be to push cart content in JSON format to your contact via API and then iterate through the items in your template to render picture, name and price for each one.\n\n### Compatibility\n\nThis plugin was tested with:\n\n* Mautic v4.4.0\n* PHP v8.0\n\nThere pluggin is compatible with other 5.x versions. Will not work with versions lower than 4.x.\n\n* Mautic 4.x - [Release 1.2](https://github.com/Logicify/mautic-advanced-templates-bundle/releases/tag/1.2)\n\n### Features\n\n* TWIG templates could be used in the emails. Just create an email and put your TWIG template between special tags:\n    ```twig\n    {% TWIG_BLOCK %} \n    Your template TWIG goes here....                                        \n    {% END_TWIG_BLOCK %}\n    ```\n* Reusable TWIG snippets could be loaded form Dynamic Content entities.\n* TWIG extended with some useful functions and filters (see below).\n* RSS support\n* RSS items related to contact's segment preferences center and RSS category\n* json_encode, json_decode twig implementations\n* \n\n## Installation\n\n1. Download or clone this bundle into your Mautic `/plugins` folder. **Make sure the name of the folder containing plugin files is** `MauticAdvancedTemplatesBundle` (case sensitive). Rename it if it isn't, otherwise it will not be recognized.\n2. Delete your cache with the command (`php bin/console cache:clear`).\n3. In the Mautic GUI, go to the gear and then to Plugins.\n4. Click \"Install/Upgrade Plugins\".\n5. You should see the Advanced Templates Bundle in your list of plugins.\n\n\n## Usage\n\nOnce installed, the plugin is ready to be used (no configuration required).\nShortly saying, the text between `{% TWIG_BLOCK %}` and `{% END_TWIG_BLOCK %}` in your emails will be treated as a TWIG template. Please check out [TWIG official documentation](https://twig.symfony.com/doc/2.x/templates.html) to familiarize yourself with syntax and capabilities.\n\nYou can also avoid lots of copy-and-paste with `include()` function available in templates. Just put reusable pieces of templates into Dynamic Content entity and use it in your main email templates (see examples below). \n\nNote: The context will be shared with included template so each variable available outside will be available in the included snippet.   \n\n### Context\n\nThe table below explains which variables are exposed to the context. Also it contains the list of extra functions and filters available. Please note that all standard library of tags\\filter\\functions as per official TWIG documents is available as well.\n\n| Entity      | Type     | Description                              | Example                                  |\n| ----------- | -------- | ---------------------------------------- | ---------------------------------------- |\n| lead        | Variable | Holds a Lead entity (contact). You should refer fields by alias name (see example). | `{{lead.firstname}}`, `{{lead.country}}` |\n| json_decode | Filter   | Converts string in JSON format into object. | `{% set cart = lead.cart | json_decode %}` In this sample we declare variable `cart` which will hold deserialized cart. |\n\n\n### Example 1: Basic scenario\n\nLet's say you'd like to add an extra paragraph about weather in New York for people from that area:  \n\n1. Navigate to the Channels / Emails / New / Builder\n2. Open the editor for the slot you need to update (Source code mode is preferable)\n3. Put the following inside your template:\n    ```twig\n    {% TWIG_BLOCK %} \n        \u003cp\u003eHi {{lead.firstname}},\u003c/p\u003e\n        {% if lead.city == 'New York' %}\n            \u003cp\u003eWhat a great weather is in New York this week!\u003c/p\u003e\n        {% endif %}\n        \n        \u003cp\u003eMain letter content goes here\u003c/p\u003e         \n    {% END_TWIG_BLOCK %}\n    ```\n\n### Example 2: Rendering structured data\n\nImaging you need to remind your prospect about incomplete purchase (Abandoned Cart feature).\n\nWe assume you have an integration with your e-commerce software which pushes cart information into Mautic contact entity in the custom field `cart`. \n\nAssume cart information is JSON and has the following format:\n\n```json\n  [\n    {\"sku\": \"123456\", \"name\": \"My cool product 1\"},\n    {\"sku\": \"8574865\", \"name\": \"My cool product 2\"}\n  ]\n```\n\nThus, in order to render all items, you should code something like this: \n\n```twig\n{% TWIG_BLOCK %} \n    {% set cart = lead.cart | json_decode %}     \n    Your cart:\n    \u003cul\u003e \n    {% for item in cart %}\n      \u003cli\u003eItem Name: {{ item.name }}\u003c/li\u003e\n    {% endfor %}\n    \u003c/ul\u003e             \n{% END_TWIG_BLOCK %}\n```\n\n### Example 3: Reusable code snippets\n\nIt might happen you need similar blocks to be included into multiple emails. In this case, it is a good idea to improve maintainability and keep common pieces in a single place. The solution this bundle offers is to leverage Dynamic Content entity and TWIG built-in function `include()`. \n\nLet's continue with the previous example but turn template for rendering a single item into a reusable snippet.\n\n1. Navigate to Components / Dynamic Content\n1. Create new entity with name `email-cart-item`.\n1. Put the following into Content area:\n    ```twig\n    \u003cli\u003eSku: {{ item.sku }}, Name: {{ item.name }}.\u003c/li\u003e\n    ```\n1. Update your email template with the following:\n    ```twig\n    {% TWIG_BLOCK %} \n        {% set cart = lead.cart | json_decode %}     \n        Your cart:\n        \u003cul\u003e \n        {% for item in cart %}\n          {{ include('dc:email-cart-item') }}\n        {% endfor %}\n        \u003c/ul\u003e             \n    {% END_TWIG_BLOCK %}\n    ```\n    Notice prefix `dc:` which instructs template resolver to look for dynamic content instance.\n    \n### Example 4: RSS support    \n    \n```twig\n     {% TWIG_BLOCK %} \n          {% set items = 'http://domain.tld/feed/' | rss %}     \n          \u003cul\u003e \n          {% for item in items %}\n              \u003cli\u003e\n               \u003ca href=''{{ item.link }}'\u003e{{ item.title }}\u003c/a\u003e ({{ item.pubDate|date('m/d/Y') }})\n               \u003cbr /\u003e{{ item.description|raw }}\n               \u003c/li\u003e\n          {% endfor %}\n          \u003c/ul\u003e             \n      {% END_TWIG_BLOCK %}\n```\n        \n    \n ### Example 5: RSS related items to contact's segments\n\n- Add one or more categories to item \nhttps://www.w3schools.com/xml/rss_tag_category_item.asp \n- Each contact receive personalized items based on segment assignemnt.\n- Matching between item categories and segment aliases\n        \n```twig\n        {% TWIG_BLOCK %} \n            {% set items = 'http://domain.tld/feed/' | rss('segments') %}     \n            \u003cul\u003e \n            {% for item in items %}\n                \u003cli\u003e\n                 \u003ca href=''{{ item.link }}'\u003e{{ item.title }}\u003c/a\u003e ({{ item.pubDate|date('m/d/Y') }})\n                 \u003cbr /\u003e{{ item.description|raw }}\n                 \u003c/li\u003e\n            {% endfor %}\n            \u003c/ul\u003e             \n        {% END_TWIG_BLOCK %}\n```\n\n### Example 6: Using `lead.tags`\n\n```twig\n        {% TWIG_BLOCK %}\n            {% set tags = lead.tags %}     \n            Tags:\n            \u003cul\u003e \n                {% for item in tags %}\n                \u003cli\u003e{{item}}\u003c/li\u003e\n                {% endfor %}\n            \u003c/ul\u003e                                           \n        {% END_TWIG_BLOCK %}\n```\n\n### Example 7: Rendering structured data from tokens\n\nInstead of pushing data to a custom field, you can specify dynamic data when using the Email Send API. When making the API call, set your POST body to a JSON object including a `tokens` key like below:\n\n```json\n{\n    \"tokens\": {\n        \"{cart}\": [{\"sku\":\"A100\",\"name\":\"Item 1\"},{\"sku\":\"Z200\",\"name\":\"Item 2\"}]\n    }\n}\n```\n\nTo render, code something like this:\n\n```twig\n{% TWIG_BLOCK %}\n  Your cart:\n  \u003cul\u003e\n  {% for item in cart %}\n    \u003cli\u003eItem Name: {{ item.name }} (SKU: {{ item.sku }})\u003c/li\u003e\n  {% endfor %}\n  \u003c/ul\u003e\n{% END_TWIG_BLOCK %}\n```\n\n## Credits\n\n - Dmitry Berezovsky, Logicify ([http://logicify.com/](https://logicify.com/?utm_source=github\u0026utm_campaign=mautic-templates\u0026utm_medium=opensource))\n - Luis Rodriguez, ldrrp/MarketSmart ([https://github.com/ldrrp](https://github.com/ldrrp)) - [Contact me on slack](https://www.mautic.org/slack)\n\n## Contributors\n\nThanks goes to these wonderful people\n\n - [Leo Giovanetti, leog](https://github.com/leog) - Lead tags implementation\n - [Ben U, bobsburgers](https://github.com/bobsburgers) - SMS implementation\n - [Felipe J. L. Rita, zerodois](https://github.com/zerodois) - Mautic 4.x compatibility\n - [Nick Pappas, radicand](https://github.com/radicand) - Arbritrary Send Mail API tokens\n - [Pablo Veintimilla, pabloveintimilla](https://github.com/pabloveintimilla) - Mautic 5 support\n\n\n## Disclaimer\n\nThis plug-in is licensed under MIT. This means you are free to use it even in commercial projects.\n\nThe MIT license clearly explains that there is no warranty for this free software. \nPlease see the included [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogicify%2Fmautic-advanced-templates-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogicify%2Fmautic-advanced-templates-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogicify%2Fmautic-advanced-templates-bundle/lists"}