modxmodx-evolutionmodx-getresources

Modx: how to use [[*published]]?


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 chunk (listtemp) I have:

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

So I would expect this should produce either:

<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?


Solution

  • getResources populates the template with placeholders ([[+placeholder]]) matching the resource fields so use

    class="listitem pub[[+published]]"
    

    in your template chunk.