We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40122
    • 330 Posts
    I am using getResources to display a list of resources, as such:

    [[!getResources? &parents=`7` &showUnpublished=`1` &sortby=`{"menuindex":"ASC"}` &limit=`100` &includeTVs=`1`  &processTVs=`1` &tpl=`listtemp` ]]


    Note that I am using `showUnpublished`.

    Now I want to add a class to resources that are published, so in my getResources template (listtemp) I have:

    <div class="listitem pub[[*published]]">


    So this should either produce:

    <div class="listitem pub1">


    or

    <div class="listitem pub0">


    but this doesnt happen.

    [[*published]] just returns '1' no matter if the resource is published or not.

    Can anyone help me out?

    Thanks!
      • 3749
      • 24,544 Posts
      To get the published status in a getResources Tpl chunk, you need this:

      [[+published]]


      Put this in the Tpl chunk where you want the class:

      <div class="pub[[+published]]>


      NB: When the resource is unpublished, the 0 may not print, so you might get pub1 and pub for the classes. Do a "view source" and adjust the class names accordingly.
        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
      • Remember, [[*...]] means "this field's value for THIS resource". That means the resource the visitor is looking at...the resource with the getResources (or other listing snippet) snippet call on it.

        The placeholders [[+...]] are set by the listing resource for each resource that it processes. That placeholder is used in the chunk tpl to show the value for each resource in the list, one by one, as the snippet loops over them.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 40122
          • 330 Posts
          Quote from: BobRay at Aug 25, 2014, 03:30 AM
          To get the published status in a getResources Tpl chunk, you need this:

          [[+published]]


          Doh! Of course. Thanks!