We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    This is an auto-generated topic for <a href="http://modxcms.com/extras/package/552">getResources 1.0.0-beta3</a> by splittingred.

    Brief Description:
    This is an initial release of getResources, a light-weight Ditto-alternative for MODx Revolution.




    - Added in snippet properties.
    - This version will only work in Revolution-2.0.0-beta5 or later.
      • 27708 MODX Staff
      • 2,502 Posts
      Just wondering if it makes sense that if you wish to display all documents that are children of the root document i.e.: ID 0 that the following line be changed as !empty returns FALSE to a 0 value vs isset which will return true to a non-empty value.

      I found this thread that offers the solution

      Current Line 70:
      <?php //for highlighting
      $parents = !empty($parents) ? explode(',', $parents) : array($modx->resource->get('id'));
      

      Could be changed to:
      <?php //for highlighting
      $parents = isset($parents) ? explode(',', $parents) : array($modx->resource->get('id'));
      


      This will allow you to set &parents=`0` (which currently returns nothing.) and output from the root.

      There may be a better way to handle this but it works as is.

      Cheers,

      Jay

        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 25483
        • 741 Posts
        I would like to have a parameter to be able to hide containers from the output.

        This is a great addition if you have a blog setup like this:

        Blog
        - 2009
        --December
        ---post1
        ---post2
        -2010
        --January
        ---post1
        --February
        ---post1
        ---post2
        ---post3

        What I want is to only show the posts, not the folders they’re in, I think the easiest is to skip "containers" from the output. Is it possible to add a parameter like that?
          with regards,

          Ronald Lokers
          'Front-end developer' @ h2o Media

          • 3749
          • 24,544 Posts
          Quote from: MediaGuy at Feb 19, 2010, 04:16 PM

          I would like to have a parameter to be able to hide containers from the output.

          Have you tried

          &hideContainers=`1`
            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
            • 25483
            • 741 Posts
            Quote from: BobRay at Feb 19, 2010, 05:05 PM

            Quote from: MediaGuy at Feb 19, 2010, 04:16 PM

            I would like to have a parameter to be able to hide containers from the output.

            Have you tried

            &hideContainers=`1`


            Forgot to post a reply here, on irc opengeek also told me to try that parameter! The problem was that it was not in the documentation nor in the drap/drop setting list.

            The parameter works perfect, just what I was looking for smiley
              with regards,

              Ronald Lokers
              'Front-end developer' @ h2o Media

              • 3749
              • 24,544 Posts
              Quote from: MediaGuy at Feb 20, 2010, 04:50 AM

              Quote from: BobRay at Feb 19, 2010, 05:05 PM

              Quote from: MediaGuy at Feb 19, 2010, 04:16 PM

              I would like to have a parameter to be able to hide containers from the output.

              Have you tried

              &hideContainers=`1`


              Forgot to post a reply here, on irc opengeek also told me to try that parameter! The problem was that it was not in the documentation nor in the drap/drop setting list.

              The parameter works perfect, just what I was looking for smiley

              I got lucky and found it in the getResources source code by searching for "container." wink
                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
                • 25483
                • 741 Posts
                Is it possible to filter dynamicly according to a TV value? I want to make a tagcloud for my blog, so I want to be able to add some parameters to the url to say which tag should be shown.
                  with regards,

                  Ronald Lokers
                  'Front-end developer' @ h2o Media

                  • 10487 MODX Staff
                  • 1,535 Posts
                  I did recently do a tag page using getResources - here is the example (note, I used getPage as a wrapper for getResources so I could have paging on the results):
                  [[!requestToPlaceholders]]
                  [[!getPage? 
                     &elementClass=`modSnippet`
                     &element=`getResources`
                  
                     &parents=`3`
                     &limit=`10`
                     &pageVarKey=`page`
                  
                     &sortby=`createdon`
                     &sortdir=`DESC`
                  
                     &includeTVs=`1`
                     &includeContent=`1`
                     &tvFilters=`tags==%[[!+modx.request.tags]]%`
                  
                     &tpl=`blogListing`
                  ]]
                  <div class="paging">
                  <ul class="pageList">
                    [[!+page.nav]]
                  </ul>
                  </div>
                  

                  In the above example, tags is my TV that contains my tag selection (I used a multi-select list but I suspect it’ll work fine with comma-delimited list as well)

                  The requestToPlaceholders is just a snippet I used to turn the $_GET parameters into placeholders so I could utilize a querystring parameter in the filtering, the contents of the snippet are:
                  <?php
                  $modx->toPlaceholders($_GET, 'modx.request');
                  return '';
                  ?>
                  
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 25483
                    • 741 Posts
                    Great, that’s just what I am looking for! smiley

                    //edit

                    Is there a way to show all results when the "tags" query isn’t used?
                      with regards,

                      Ronald Lokers
                      'Front-end developer' @ h2o Media

                      • 36541
                      • 222 Posts
                      What a useful snippet! Would it be possible to extend it a bit to make it useful even more?


                      • Allow to select resources directly (not their parents) and add them to the collection by, say, [tt]&resources=`id[, id]`[/tt]? It should be possible not to select any parents, and collect only resources of choice. Of course, the [tt]&depth[/tt] parameter should be ignored in this case.

                        That will allow to collect resources into a hand made list and, in special case, return value for a single resource a la Evo’s getField snippet.

                      • Allow to use in-line template without need for the [tt]@INLINE[/tt] binding, which is not documented nor standard for MODx.

                      I filed a feature request for this: http://svn.modxcms.com/jira/browse/ADDON-160
                        This is the web: the only thing you know about who will come is that you don't know who will come.