We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi,

    I’m using ditto to display some articles, and I’m adding a new image that is displayed next to new articles. But I only want this display if the article was added in the last 30day. Any idea what i’d need to do here. I’m guessing phx but not sure exactly how.

    Any help would be great.

    Thanks

    Ben
      • 4310
      • 2,310 Posts
      Just add this parameter to your Ditto snippet call :
      &filter=`pub_date,@EVAL return time() - (30 * 24 * 60 * 60);,3`
        • 20413
        • 2,877 Posts
        Cool stuff! smiley
        http://www.informit.com/articles/article.aspx?p=418002&seqNum=7

        So if you wanted to list everything you would use two Ditto calls:
        [[Ditto?id="one" &filter=`pub_date,@EVAL return time() - (30 * 24 * 60 * 60);,3` &tpl=`one`]]
        
        <strong>Older articles...</strong>
        [[Ditto?id="two" &filter=`pub_date,@EVAL return time() - (30 * 24 * 60 * 60);,4` &tpl=`two`]]
        
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 36926
          • 701 Posts
          Thanks you both. But my calls now don’t return any documents.

          The call I originally had and worked was:

          [!Ditto? parents=`4` &tpl=`feature.Tpl` &sortDir=`DESC` &sortBy=`pub_date` &dateSource=`pub_date` &dateFormat=`%b %G` &display=`all`!]
          


          i now have this, which return "no documents found"
          [!Ditto?id="one" &filter=`pub_date,@EVAL return time() - (30 * 24 * 60 * 60);,3` parents=`4` &tpl=`feature.Tpl` &sortDir=`DESC` &sortBy=`pub_date` &dateSource=`pub_date` &dateFormat=`%b %G` &display=`all`!]
          [!Ditto?id="two" &filter=`pub_date,@EVAL return time() - (30 * 24 * 60 * 60);,4` parents=`4` &tpl=`featureOld.Tpl` &sortDir=`DESC` &sortBy=`pub_date` &dateSource=`pub_date` &dateFormat=`%b %G` &display=`all`!]
          


          I’ve tried stripping the call down to the bare min and still no joy.

          Also is the id="one" & id="two" required if you have multiple calls on one page?

          Thanks again for you help

          Ben
            • 20413
            • 2,877 Posts
            Yes, you need to set an id for each call and
            use &parents=`4` instead of parents=`4`
            The only time you can skip the "&" is when it comes right after "?" wink

            When using id - you will need to set it in pagination placeholders ([+two_next+]..)
            and if using request extender (page.html?ditto_two_sortBy=...)
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 36926
              • 701 Posts
              Quote from: mrhaw at Dec 14, 2009, 11:18 PM

              Yes, you need to set an id for each call and
              use &parents=`4` instead of parents=`4`
              The only time you can skip the "&" is when it comes right after "?" wink

              When using id - you will need to set it in pagination placeholders ([+two_next+]..)
              and if using request extender (page.html?ditto_two_sortBy=...)

              Just checking the forums again after a long xmas breaking and seen your reply. Doh completely missed the missing &, I’ll give this ago. Thanks for the help

              Ben