We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    This is an auto-generated topic for getResources 1.2.1-pl by opengeek.

    Brief Description:


    getResources 1.2.1-pl (October 11, 2010)


    • Remove inadvertent call to modX::setLogTarget(’ECHO’)

      • 25674
      • 2 Posts
      Hi,
      I am getting strange behaviours when I specify &outputSeparator=`` in my call to getResources.
      Sometimes it does not render anything, sometimes it does a dump of Arrays for the found resources.
      Either way, it is not helpful.

      I am using it to generate a menu of the found resources (pretty common use), but the default outputSeparator is a newline "\n".
      Browsers render this newline as a space, where I do not want an additional space in between my menu items. It messes with my menu hovers.

      To get around this I had to specify &outputSeparator=`<!-- -->`
      i.e. an empty comment.

      Let me know if you don’t get these issues, and if I am doing something incorrectly.
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: RubberDuck at Oct 11, 2010, 09:03 PM

        Hi,
        I am getting strange behaviours when I specify &outputSeparator=`` in my call to getResources.
        Sometimes it does not render anything, sometimes it does a dump of Arrays for the found resources.
        Either way, it is not helpful.

        I am using it to generate a menu of the found resources (pretty common use), but the default outputSeparator is a newline "\n".
        Browsers render this newline as a space, where I do not want an additional space in between my menu items. It messes with my menu hovers.

        To get around this I had to specify &outputSeparator=`<!-- -->`
        i.e. an empty comment.

        Let me know if you don’t get these issues, and if I am doing something incorrectly.
        I cannot reproduce this behavior at all. Using &outputSeparator=`` works as expected as far as I can tell. You do have to make sure you do not have a new line at the end of your Chunk tpl that you are using in order for it not to produce a new line in between each item, but otherwise, it renders exactly as expected for me.

        FWIW, the only time getResources will dump an array of the placeholders that are made available to your tpl is when no tpl is specified (or no results have been returned by the one specified).
          • 1343 ☆ A M B ☆
          • 2,213 Posts
          I’ve been using this a lot on an upcoming site and noticed there isn’t a no result option.

          It would be great if I could have &noresult=`chunk` instead of using If to replicate the function. Any chance of getting this added, or is there a reason this wasn’t added?
            Patrick | Server Wrangler
            About Me: Website | Tweets |  MODX Hosting
            • 22303 MODX Staff
            • 10,725 Posts
            [[getResources:default=`<p>Nada</p>`]]
              • 1343 ☆ A M B ☆
              • 2,213 Posts
              Could I use that to call a chunk? And i’m guessing I would just put everything else after that?

              [[getResources:default=`<p>Nada</p>` &depth=`5`....]]
                Patrick | Server Wrangler
                About Me: Website | Tweets |  MODX Hosting
                • 22303 MODX Staff
                • 10,725 Posts
                You still need the ? to start the tag property string. The syntax for tags in Revolution is:

                [[ (opening tags)
                ! (optional non-cacheable flag)
                elementToken (optional token identifying the element type if it’s not a snippet, $=chunk, *=resource field/tv, +=placeholder, etc.)
                elementName
                @propertyset (optional PropertySet identifier)
                :filterName=`modifier`:... (optional one or more output filters)
                ? (optional; indicates beginning of property string)
                &propertyName=`propertyValue` &... (optional; any additional properties separated by &)
                ]] (closing tags)

                So, for example, your call might look like this:
                [[getResources:default=`<p>Nada</p>`? &depth=`5` &parents=`0` &includeContent=`1` &sortby=`menuindex`]]

                An example with every possible type of tag element:
                [[!getResources@homepage:default=`<p>Apparently I don't write anything for my blog.</p>`? &sortby=`RAND()`]]
                  • 26303
                  • 27 Posts
                  I’m using a template variable to sort with. For a TV of input type text and output type default, this works fine:

                  [[getResources? &sortby=`[[*Title]]`]]

                  But if the TV is of input and output type date it fails. I was expecting an output filter to work:

                  [[getResources? &sortby=`[[*Date:strtotime]]`]]

                  But it doesn’t. Thoughts?
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Quote from: SBM at Oct 13, 2010, 02:45 PM

                    I’m using a template variable to sort with. For a TV of input type text and output type default, this works fine:

                    [[getResources? &sortby=`[[*Title]]`]]

                    But if the TV is of input and output type date it fails. I was expecting an output filter to work:

                    [[getResources? &sortby=`[[*Date:strtotime]]`]]

                    But it doesn’t. Thoughts?
                    That is not the correct way to sort by the TV’s. You need to use the name of the TV in the sortbyTV property, not the TV tag in the sortby property, e.g.
                    [[getResources? &sortbyTV=`Title` &sortdirTV=`ASC` &sortby=``]]
                      • 26303
                      • 27 Posts
                      Thanks for this. I didn’t see &sortbyTV or &sortdirTV documented anywhere; I guess I need to get in the habit of taking a look at the properties on snippets when I upgrade them.

                      Still, I can’t get it working. I assume that having the empty &sortby=`` in there is important. But whether I include it or not some resources are getting duplicated in the output. Not ALL, of course, and I can’t figure out the logic of which ones are getting duplicated--but which ones are duplicated changes when I change the sort order.

                      It’s a simple call with just 3 resources at the moment:

                      [[getResources? &tpl=`getResMainTpl` &parents=`[[*id]]` &sortbyTV=`Title` &sortdirTV=`ASC` &sortby=`` &includeTVs=`1` &processTVs=`1`]]

                      It actually works perfectly just plugging in the full TV tag in the &sortby property, but as I said I couldn’t get it to work with a date formatted TV.

                      So is there some sort of interaction between &sortby and &sortbyTV that is tripping me up here? Thanks again!