We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46241
    • 16 Posts
    I am running Modx Revo 2.2.8pl and 2.2.10pl with getResources 1.6.1pl on 1and1 hosting.
    I am having a hard time getting resources info displayed.

    I created 2 pages under Home, i.e. Home 2 and Home 3.
    Using this code:
    [[getResources:default=`No results found`? &parents=`[[*id]]` &showHidden=`1` &tpl=`@INLINE <li title="[[+longtitle]]">page - [[+pagetitle]]</li>`]]
    I get:
    page - Home 2
    page - Home 3

    Using this code:
    [[getResources:default=`No results found`? &parents=`[[*id]]` &showHidden=`1` &tpl=`pageIndex`]]
    pageIndex contains <li title="[[+longtitle]]">page - [[+pagetitle]]</li>
    I get:
    No results found
    I expected the same as above.
    SOLVED: pageIndex needs to be a chunk and not a template, even though the parm is tpl.

    Using this code:
    [[getResources:default=`No results found`? &parents=`[[*id]]` &showHidden=`1`]]
    I get:
    No results found.
    I expected a list of properties.

    Clearly I am doing something incorrectly does anyone have an idea as to what is wrong?

    Looking at the changelog for getResources 1.6.1pl :
    Only dump properties for invalid tpl when debug enabled

    Well that sucks! The one thing I figured would be really useful in learning/developing has been removed, so none of the documentation/examples cannot be trusted.
    I will continue with the previous version for this first project and switch to pdoResources for the next. [ed. note: davidryman last edited this post 10 years, 6 months ago.]
    • That's why it's called a tpl, and not a template. It is technically a template for the snippet's output, but calling them "templates" was too confusing.

      As far as not getting the array of properties if no tpl is specified, I suspect that the 'default' option is overriding everything other than a valid output.
        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
        • 3749
        • 24,544 Posts
        Have you tried this?

        [[!getResources? &parents=`[[~[[*id]]` &showhidden=`1` &debug=`1` &tpl=`xxx`]]
          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
          • 46241
          • 16 Posts
          Thanks,
          Quote from: BobRay at Jan 22, 2014, 09:10 AM
          Have you tried this?

          [[!getResources? &parents=`[[~[[*id]]` &showhidden=`1` &debug=`1` &tpl=`xxx`]]

          &debug=`1` 
          is key. I take back the
          Well that sucks
          apparently it is me who sucks:)
          I'll be OK once I get in the ModX mindset.

          I have not figured out what you meant by the missmatched brackets
          [[~
          . Can we use negation?
          • &parents=`[[~[[*id]]`

            is a problem. The parents property takes a resource ID. The [[~...]] tag will generate a URL from a given resource ID. What you have there is a partial URL tag for making a URL out of the current resource's ID. The proper tag for such a thing would be
            [[~[[*id]]]]

            But I presume that is not what you meant.
              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
              • 46241
              • 16 Posts
              Thanks,
              Quote from: sottwell at Jan 21, 2014, 08:23 PM
              That's why it's called a tpl, and not a template. It is technically a template for the snippet's output, but calling them "templates" was too confusing.

              As far as not getting the array of properties if no tpl is specified, I suspect that the 'default' option is overriding everything other than a valid output.

              Sorry I thought tpl was template!
              I have the tpl as a Chunk. Can either be used, and am I correct that Chunks are js and Snippets PHP?

              If you have resources returned and no tpl (or more likely an incorrect tpl) what would you want to see returned? Personally, I would want '3 resources found, invalid tpl'.
              Is there a place to specify a default tpl to use?
              On the change log for 1.6.1-pl are [#30][#80], which I assume are feature requests or bug reports. I will go research them to find out more.
                • 46241
                • 16 Posts
                Quote from: sottwell at Jan 22, 2014, 06:54 PM
                &parents=`[[~[[*id]]`

                is a problem. The parents property takes a resource ID. The [[~...]] tag will generate a URL from a given resource ID. What you have there is a partial URL tag for making a URL out of the current resource's ID. The proper tag for such a thing would be
                [[~[[*id]]]]

                But I presume that is not what you meant.

                Duh! and I have tilde on my cheatsheet, my bad.
                • Chunks are any HTML code, including text, HTML tags, other MODX tags, and javascript. They used to be call "htmlsnippets", and in fact that is still the name of their table in the database.

                  Snippets are PHP code.

                  Templates are the site templates that format your entire page; they are managed in the "Templates" section of the Elements tab.

                  "tpls" are the mini-templates used by snippet to format the snippet output. They're specifically called "tpls" to differentiate them from the main site templates. They can be chunks, but sometimes the snippet allows files, inline tpl definitions, and some even allow resource content. But in all cases, they are applied only to the snippet's output, in the case of listing snippets like getResources or Wayfinder, the same tpl is applied to each item the snippet is processing.

                  getResources should return an array containing a bunch of values for each item it finds if no tpl is specified.
                    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