We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42191
    • 6 Posts
    MODX Revolution 2.2.4
    getResources 1.5.1

    Need help to deal with this:

    - resource X: published, is a parent to a few children that aren't hidden from menu and also published
    - what i want: unpublish resource X and all it's children
    - what i do: I make resource X "unpublished"
    - what i get: resource X disappears, but it's children is still showing

    How can i make getResources show only resources with published parents?

    (it's like if i need to unpublish whole category but i will have to unpublish each child - very awkward, isn't it?)
      • 3109 ☆ A M B ☆
      • 894 Posts
      You can use the &resources property to exclude the children by prefixing their id with a - that seems like a faster solution than unpublishing each resource.

      More info here: http://rtfm.modx.com/display/ADDON/getResources
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 42191
        • 6 Posts
        Quote from: benmarte at Nov 28, 2012, 11:27 AM
        You can use the &resources property to exclude the children by prefixing their id with a - that seems like a faster solution than unpublishing each resource

        Bad idea.

        It's a question of usability. Imagine if you've got thousands of resouces and containers (for example, shop or catalog) and every time you need to unpublish some category, you have to unpublish hundreds of child resources. Easy? Imagine this as if you were just a content manager (not a developer).
          • 42191
          • 6 Posts
          I've found a workaround for my case. I made a snippet to list published containers:

          [[getResources?
          &parents=`[[getchildcontainers]]`
          &depth=`0`
          ...]]


          Snippet:

          <?php
          $outarr = array();
          $parent = (!empty($parent)) ? $parent : $modx->resource->get('id');
          $idsarr = $modx->getChildIds($parent,10);
          foreach ($idsarr as $idx){
              $obj = $modx->getObject('modResource',$idx);
              if ( $obj->get('published') == 1 && $obj->get('isfolder') == 1 ){
                  $outarr[] = $idx;
              }
          }
          $out = implode(",", $outarr);
          return $out;


          But it's not so good. I whish there should be an option in getResources to make my dreams come true. [ed. note: sergeybrin last edited this post 13 years, 10 months ago.]