We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    Since Evo, with ditto, ajaxSearch, and some other snippets, to define a list of id (in order to restrict the area of list/search), we use the "classical" parameters &documents or &parents with &depth.

    With getResources for Revo, we use always &parents and &depth. With &parents parameter, if you specify &parents=`28,42` you get #28 and all children of #28 (if #28 if a parent document), #42 and children of #42 (if #42 if a parent document).

    But this specification is not efficient if I would like:

    - Children of #28 but not the document #28 ? For this, I probably need to list ll the children id of #28. Not very convenient sad

    - Document #28 and #36 with the first level of children. If I use depth = 0, I got 28, but not the children of #36. If I choose depth = 1 I get #36 but also the children of #28 >:(

    - All the parents of #28 but not #28 nor documenbt #0 and document #1 ? huh

    - All the children of the document #28 but not the children document of #36 which is a child of 28 and a parent of a subtree ? How could I exclude this document sub-tree ? embarrassed



    A solution could be to specify documents parameter like this: &documents=`comma separated list of prefixedId` avec prefixedId=[[ |+|-][ |c|p]id ]

    With this specification:

    - Children of #28 but not the document #28 ? &documents=`c28` => c for chidren (#28 excluded)

    - Only #28 and #36 with the first child ? &documents=`28, 36, c36` => #28, #36, and children of #36

    - All the parents of #28 but not 28 nor 0 or 1 ? &documents=`p28, -0, -1` => p for parents (#28 excluded),#0 and #1 excluded (- for excluded)

    - All the children of #28 but not the children of #36 ? &documents=`c28, -c36` => children of #28 and children of #36 excluded (#36 included)


    It could be interesting that all addons implement this general &documents parameter like this. Does it make sense or is it too complicated or sophisticated ?


    Hereafter the code which implement for Revo this parameter[Edit] A snippet named GetIds is now available in the utilities section of the repository.
      • 3749
      • 24,544 Posts
      Some interesting ideas.

      This isn’t exactly what you want, but it is in the getResources comments:

      /* include/exclude resources, via &resources=`123,-456` property */


      You can also include and exclude children in the front end by putting them in resource groups. If you put children in a protected resource group, getResources won’t show them.
        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
        • 5811
        • 1,717 Posts
        Resources groups could be a solution, but this implied to defined a group each time before to use it.

        With getResources, &resources parameter exclude the resources at the end of the list construction. Which is a bit different.


        As I think that it could be usefull, I have proposed a snippet named GetIds (Utility section), which can be used to fill &resources for getResources or &documents for ditto. I hope It can help.


        e.g: [[!getResources? &resources=`[[!GetIds? &ids=`18, c18, -c21, 34`]]` &limit=`100` &tpl=`blogPost`]]


        Hereafter is the header of this snippet:
        /**
         * getIds
         *
         * A general purpose snippet to get a list of resource ids for MODx 2.0.
         *
         * [[!GetIds? &depth=`5` &ids=`8,-c10,12,3,c3`]]
         *
         * depth - (Opt) Integer value indicating depth to search for resources from each parent
         *
         * ids - Comma-delimited list of resource ids serving as parents, child or resource
         *
         * ids as [ [+| |-] [c| |p]integer ] where:
         *
         *  - : exclude ids             + or '' : include ids (default)
         *  p : parents resources       c : children resources      '': current resource
         *
         * e.g:
         *
         * &ids=`18, c18, -c21, 34` : include #18 and children of #18, exclude chidren of #21 but keep #34
         *
         * &ids=`p12, -p3, -1, 2`   : include all parents of #12, exclude parents of #3 but keep #2
         *
         * &ids=`18, c18, p3, -p2`  : include #8 and children of #8, include parents of #3, exclude parent of #2
         *
         *
         * IMPORTANT: take care of the order of arguments. To be excluded the id should be already in the list
         * &ids=`18, 19, -19, 20` => '18,20'          but &ids=`18, -19, 19, 20` => '18,19,20'
         *
         */


        You could download the snippet from http://modxcms.com/extras/search.html?query=getIds
          • 3749
          • 24,544 Posts
          Very nice. I’m sure it will get a lot of use. cool

          Once you have it the way you want it, you could package it up with PackMan and release it.
            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
            • 5811
            • 1,717 Posts
            Thanks. Packaged and downloadable from http://modxcms.com/extras/search.html?query=getIds

            I have done lot of tests with crazy ids like ’ ,z ,- ,cz ,c- ,-c ,-2 ,zzz ,zz+ ,zc+ ,+zc ,+cz ,c+3 ,+c3 ,p22 ,+22 ,+2, -22, 2, +222, -222, 222’
            Hope all is correct
              • 25663 MODX Staff
              • 12,272 Posts
              I agree with Bob, this should be a great snippet that man other developers could use and not have to handle that bit. Great job!
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 21417
                • 486 Posts
                This sounds phenomenal, exactly what I need for Evo and AjaxSearch.
                I wish there was an Evo version to help with excluding children resources of known parents from AjaxSearch results - https://forums.modx.com/thread/91767/exclude-children-of-known-parents-from-ajaxsearch-results
                  Web design Adelaide
                  http://gocreate.com.au
                  • 20413
                  • 2,877 Posts
                  Quote from: nickf08 at Jun 28, 2014, 01:10 AM
                  This sounds phenomenal, exactly what I need for Evo and AjaxSearch.
                  I wish there was an Evo version to help with excluding children resources of known parents from AjaxSearch results - https://forums.modx.com/thread/91767/exclude-children-of-known-parents-from-ajaxsearch-results

                  No need for it! wink https://forums.modx.com/thread/91767/exclude-children-of-known-parents-from-ajaxsearch-results#dis-post-501735

                  My guess is that this is exactly why coroico (author of AjaxSearch) wanted this feature and wrote this snippet. [ed. note: mrhaw last edited this post 12 years, 3 months ago.]
                    @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