We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36632
    • 202 Posts
    By default getResources showUnpublished shows both Published and Unpublished.

    How do I get it to display only those that are unPublished?

    Is there a way I could use the 'offset' property to do that?
      • 22303 MODX Staff
      • 10,725 Posts
      Use the where property in conjunction with showUnpublished, e.g.

      [[getResources? &showUnpublished=`1` &where=`{"published" : false}`]]
        • 36632
        • 202 Posts
        Thank you Jason!
          • 36632
          • 202 Posts
          The above code,
          &where=`{"published" : false}`
          no longer works because I'm using property sets. I'm not having success with the various way I've tried to filter a folder's contents by whether it is unpublished or not.

          If it's published, display them here.

          If it's not published, display them down here.

          2 separate calls.

          I tried a property set
          {"unpublished:=" "true"}

          that displayed all of the resources.

          I tried tvFilters instead
          `unpublished==true`

          and that didn't display anything.

          I really like working with property sets, but it's kinda maddening to have this much flexibility, and to memorize all of the various parameters possible to achieve desired results.

          [ed. note: ultrasef last edited this post 13 years, 2 months ago.]
            • 3749
            • 24,544 Posts
            Using `unpublished` will never work because there is no 'unpublished` resource field. You have to use the `published` field, which is set to 0 (false) or 1 (true).

            You're also using "true" as the value to check for. That's won't work either since the actual value of the 'published' field is a 1 or a 0 and you're asking it to look for the string "true". You can use true or false, but you can't put them in quotes.

            I can't think of any reason why using a property set would affect whether a property works or not. Properties in a property set are passed to the snippet just like the default properties or the ones in the snippet tag, though properties in the snippet tag will override everything else.

            BTW, there's no real advantage to using a property set rather than putting properties in the snippet tag, other than your convenience.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 36632
              • 202 Posts
              Thanks for replying

              With this code
              &where   {"published:=" "0"}  

              in the property set
              - yes, I love convenience because it can build a series of chunks with conditionals and other TVs as needed -
              it still displays all events, regardless of its publish status.

              If I set the &showHidden to False, the call displays only the published. But this &where published=0 displays them all with the &showHidden=True Maybe I need a new property &showPublished so I can set it to False?
              [ed. note: ultrasef last edited this post 13 years, 2 months ago.]
                • 3749
                • 24,544 Posts
                Try this:


                [[getResources? &showHidden=`1` &showUnpublished=`1` &where=`{"published" : false}`]]
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 36632
                  • 202 Posts
                  Thanks Bob. That worked.
                    • 3749
                    • 24,544 Posts
                    Glad I could help (though it's really OpenGeek's suggestion with &showHidden=`1` added). Thanks for reporting back. smiley
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting