Logicify / mautic-advanced-templates-bundle

Plugin extends default email template capabilities with TWIG block so you can use advanced scripting techniques like conditions, loops etc
https://logicify.com/?utm_source=github&utm_campaign=mautic-templates&utm_medium=opensource
MIT License
90 stars 57 forks source link

Json data not working while rss is working #42

Closed geminigeek closed 2 months ago

geminigeek commented 2 months ago

hi,

there is an issue with json data , when i am using an endpoint to send rss its working fine, with json its not, find below my code for rss and json, i am fairly new to mautic. I'll appreciate any help or feedback.

one of the finding is that my json endpoint is not getting hit at all with my code below

working rss

 {% TWIG_BLOCK %} 
          {% set items = 'http://192.168.1.11:3009/rss' | rss %}     
          <ul> 
          {% for item in items %}
              <li>
               <a href='{{ item.link }}'>{{ item.title }}</a> 
               <br />{{ item.description|raw }}
               </li>

          {% endfor %}
          </ul>

  {% END_TWIG_BLOCK %}

not working json

 {% TWIG_BLOCK %} 
          {% set items = 'http://192.168.1.11:3009/json' | json_decode %}     
          <ul> 
          {% for item in items %}
              <li>
               <a href='{{ item.link }}'>{{ item.title }}</a> 
               <br />{{ item.description|raw }}
               </li>

          {% endfor %}
          </ul>

  {% END_TWIG_BLOCK %}

json payload

[
  {
    "title": "title-0",
    "description": "description-0",
    "feed_url": "http://example.com/rss.xml-0",
    "link": "http://example.com/rss.xml-0",
    "site_url": "http://example.com-0",
    "image_url": "http://example.com/icon.png-0"
  },
  {
    "title": "title-1",
    "description": "description-1",
    "feed_url": "http://example.com/rss.xml-1",
    "link": "http://example.com/rss.xml-1",
    "site_url": "http://example.com-1",
    "image_url": "http://example.com/icon.png-1"
  },
  {
    "title": "title-2",
    "description": "description-2",
    "feed_url": "http://example.com/rss.xml-2",
    "link": "http://example.com/rss.xml-2",
    "site_url": "http://example.com-2",
    "image_url": "http://example.com/icon.png-2"
  },
  {
    "title": "title-3",
    "description": "description-3",
    "feed_url": "http://example.com/rss.xml-3",
    "link": "http://example.com/rss.xml-3",
    "site_url": "http://example.com-3",
    "image_url": "http://example.com/icon.png-3"
  },
  {
    "title": "title-4",
    "description": "description-4",
    "feed_url": "http://example.com/rss.xml-4",
    "link": "http://example.com/rss.xml-4",
    "site_url": "http://example.com-4",
    "image_url": "http://example.com/icon.png-4"
  }
]

seems related to this https://github.com/Logicify/mautic-advanced-templates-bundle/issues/25

geminigeek commented 2 months ago

i think i am wrong to expect the json url will work as it load file with simplexml_load_file, i will find some other way