On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • I have the rather easy task of making a RSS feed builder in MODx 2.0.6 pl2.

    As I see it this is very easy done with Ditto but not so easy with getResources.

    When I read about getResources it says that you could still use Ditto and other extras for special cases.

    But when I read about Ditto it says that there will not be any further development on Ditto.

    So which one should I use for my purpose?
    • getResources. In the new MODX site here’s how we’re implementing them.

      [*] Use a blank template
      [*] Make the Content Type RSS with Inline Disposition
      [*] Put the following in the content, replacing the relevant bits, like the &parents=`` param ... you could also leave out the TVs since we are using a custom date for sorting (porting over older blog entries)

      <?xml version="1.0" encoding="UTF-8"?>
      <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
          <title>[[*pagetitle]]</title>
          <link>[[~[[*id]]? &scheme=`full`]]</link>
          <description>[[*pagetitle:cdata]]</description>
          <language>[[++cultureKey]]</language>
          <ttl>120</ttl>
          <atom:link href="[[~[[*id]]? &scheme=`full`]]" rel="self" type="application/rss+xml" />
      [[!getResources?
        &tpl=`rssItem`
        &parents=`51`
        &limit=`10`
        &includeContent=`1`
        &includeTVs=`1`
        &showHidden=`1`
        &hideContainers=`1`
        &cache=`0`
        &sortbyTV=`article_date`
      ]]
      </channel>
      </rss>


      And our Chunk:
      <item>
          <title>[[+pagetitle]]</title>
          <link>[[++site_url]][[~[[+id]]]]</link>
          <description>
          [[+tv.article_source:is=``:then=`[[+content:cdata]]`:else=`[[+introtext:cdata:default=`[[+content]]`]]`]]
          </description>
          <pubDate>[[+tv.article_date:strtotime:date=`%a, %d %b %Y %H:%M:%S -0600`]]</pubDate>
          [[+tv.tags:notempty=`<category>[[+tv.tags]]</category>`]]
          <guid isPermaLink="false">[[++site_url]][[~[[+id]]]]</guid>
          <dc:creator>[[+tv.article_source:default=`[[+tv.blog.AuthorID:userinfo=`fullname`]]`]]</dc:creator>
      </item>
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • Thanks!

        That lokks just nice to me.

        Regards Erik.
        • Great example!
          Just 1 small issue: can it include TV? The docs says it’s possible, right?! But this:

          <rss>
          .
          ...
          .....
          <language>en-gb</language>
          [[!getResources? &parents=`58` &tpl=`rssListing` &includeTVs=`1` &processTVs=`1` &tvPrefix=``]]
          </channel>
          </rss>

          does not seem to work.. I mean no tv value is in output when i try [[+AssignedTV]]
            modx and ecommerce pro
          • Shouldn’t be any trouble including TVs.. just need to prefix them with tv. smiley

            http://rtfm.modx.com/display/ADDON/getResources#getResources-DisplayingTemplateVariableswithgetResources

            You can also change the prefix with &tvPrefix


            For future reference, how to create RSS feeds with getResources can also be found on the RTFM: http://rtfm.modx.com/display/ADDON/getResources.Building+a+RSS+feed
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • Thanks, you are right there should not be any trouble & my call is [[!getResources? &parents=`58` &tpl=`rssListing` &includeTVs=`1` &processTVs=`1` &tvPrefix=``]] where i do specify &tvPrefix but probebly incorrect?
                modx and ecommerce pro
              • Oh I missed that in your call, sorry.

                Can you just try leaving that parameter with value "tv." and prefix it in your tpl? Maybe it doesn’t allow blank values.
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • it’s ok thanks,

                  well, i removerd the parameter of tvprefix,

                  <item>
                        <title>[[+pagetitle:toCDATA]] </title>
                        <link>[[++site_url]][[~[[+id]]]]</link>
                        <guid>[[++site_url]][[~[[+id]]]]</guid>
                        <pubDate>[[+createdon:strtotime:date=`%a, %d %b %Y %H:%M:%S %z`]]</pubDate>
                        <description>[[+introtext:toCDATA]] ~[[+tv.location]]</description> 
                  </item>

                  but i still have an empty string after description and ~
                  so the placeholder [[+tv.location]] does not work i am afraid, I mean it does NOT being pulled out to HTML source at all, strange, can you view a private link of that?
                    modx and ecommerce pro
                  • You’re saying it is visible in the source, but not in the feed? In that case your feed is off, and as you’re wrapping the introtext in cdata, the rest might just be left out...
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • sorry, my mistake.
                      it ’s not seen in HTML source code
                        modx and ecommerce pro