We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36541
    • 222 Posts
    Also, I got questions regarding parameters:


    • [tt]sortbyAlias[/tt]
    • [tt]sortbyEscaped[/tt]
    • [tt]idx[/tt]
    • [tt]first[/tt]
    • [tt]last[/tt]

    What are they for and how to use them? An example would be certainly help.
      This is the web: the only thing you know about who will come is that you don't know who will come.
      • 36541
      • 222 Posts
      And the last question in this take: how to iterate through the result list?

      I use the snippet for news listing, which is placed right under the news content. I want to:


      • Exclude (or even better mark) the item being displayed.
      • Provide next/previous links to sibling items in the list (members and sorting criteria are important).

      How can I achieve that with [tt]getResources[/tt]?
        This is the web: the only thing you know about who will come is that you don't know who will come.
        • 3749
        • 24,544 Posts
        Google is your friend:

        search for: modx revolution documentation getresources
          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
          • 36541
          • 222 Posts
          I must admit, I’m always confused by replies like yours, Bob. Anyway, thanks for your effort.

          Quote from: BobRay at Jul 24, 2010, 04:59 PM

          Google is your friend:

          I asked for a feature, explanation of options (I studied the documentation first) and an advice on the specific issue. Which of those this search will answer to in your opinion?
            This is the web: the only thing you know about who will come is that you don't know who will come.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: gadamiak at Jul 25, 2010, 08:43 AM

            I asked for a feature, explanation of options (I studied the documentation first) and an advice on the specific issue. Which of those this search will answer to in your opinion?
            You studied this? http://svn.modxcms.com/docs/display/ADDON/getResources#getResources-AvailableProperties ? Because I think each property you asked about is described there. And the whole point of getResources is to iterate through the results, so I don’t understand that part of the inquiry.

            Also, can you file feature requests for this add-on at http://github.com/opengeek/getResources/issues moving forward?

            I will say that some of these features might not get implemented in getResources, but it should be trivial to use getResources as a basis to implement a custom solution for more complex requirements.

            FWIW, using @INLINE tpl is a problem anyway and will probably be removed from future versions. Any support for this will need to be done in the Revo core IMO.
              • 36541
              • 222 Posts
              Quote from: OpenGeek at Jul 25, 2010, 10:27 AM

              You studied this? Because I think each property you asked about is described there. And the whole point of getResources is to iterate through the results, so I don’t understand that part of the inquiry.

              Yes. I intentionally posted 3 separate posts, as there are 3 subjects. In case of properties, they are described, however, it’s not clear for me. I mean: how to use them? what’s the intended use for them? It may be my understanding in English too, I guess.

              Also, can you file feature requests for this add-on at http://github.com/opengeek/getResources/issues moving forward?


              I will say that some of these features might not get implemented in getResources, but it should be trivial to use getResources as a basis to implement a custom solution for more complex requirements.

              In fact I considered to modify getResources myself, but 1) Revo scripting is cryptic to me, although I did some coding back in 0.9.6 days and 2) I’ve been away from PHP and coding in general for those years and it’s not easy to come back.

              I need functionality similar to my getField for Evo and thought extending an existing snippet should be the way to go rather than adding another one. getResources does the thing for child resources but why couldn’t it work for the explicit collection too?

              FWIW, using @INLINE tpl is a problem anyway and will probably be removed from future versions. Any support for this will need to be done in the Revo core IMO.

              AFAIR, Ditto works with in-line templates like this [tt]&tpl=`my [[+placeholder]]`[/tt] and that’s what I mean.
                This is the web: the only thing you know about who will come is that you don't know who will come.
                • 22829 ☆ A M B ☆
                • 80 Posts
                This is what I use for GetField type stuff in Revo:

                <?php
                /**
                 *
                 * getResourceField
                 *
                 * A snippet to grab a value from a field or a TV
                 *
                 * @ author Paul Merchant
                 * @ author Shaun McCormick
                 * @ version 1.0.0 - April 30, 2010
                 *
                 * OPTIONS
                 * id - The resource ID
                 * field - (Opt) The field or template variable name, defaults to pagetitle
                 * isTV - (Opt) Set as true to return a raw template variable
                 * processTV - (Opt) Set as true to return a rendered template variable
                 * default - (Opt) The value returned if no field is found
                 *
                 * Exmaple1: [[getResourceField? &id=`123`]]
                 * Example2: [[getResourceField? &id=`[[UltimateParent?]]` &field=`myTV` &isTV=`1`]]
                 * Example3: [[getResourceField? &id=`[[*parent]]` &field=`myTV` &processTV=`1`]]
                 *
                **/
                
                // set defaults
                $id = $modx->getOption('id',$scriptProperties,$modx->resource->get('id'));
                $field = $modx->getOption('field',$scriptProperties,'pagetitle');
                $isTV = $modx->getOption('isTV',$scriptProperties,false);
                $processTV = $modx->getOption('processTV',$scriptProperties,false);
                $output = $modx->getOption('default',$scriptProperties,'');
                
                if ($isTV || $processTV) {
                    // get the tv object
                    $tv = $modx->getObject('modTemplateVar',array('name'=>$field));
                    if (empty($tv)) return $output;
                    if ($processTV) {
                        // get rendered tv value
                        $tvValue = $tv->renderOutput($id);
                    } else {
                        // get raw tv value
                        $tvValue = $tv->getValue($id);
                    }
                    if ($tvValue !== null) {
                        $output = $tvValue;
                    }
                } else {
                    if ($id == $modx->resource->get('id')) {
                        // use the current resource
                        $resource =& $modx->resource;
                    } else {
                        // grab only the columns we need
                        $criteria = $modx->newQuery('modResource');
                        $criteria->select($modx->getSelectColumns('modResource','modResource','',array('id',$field)));
                        $criteria->where(array('id'=>$id));
                        $resource = $modx->getObject('modResource',$criteria);
                        if (empty($resource)) return $output;
                    }
                    $fieldValue = $resource->get($field);
                    if ($fieldValue !== null) {
                        $output = $fieldValue;
                    }
                }
                
                return $output;
                ?>


                I’ve been using it without problems for a couple of months. Maybe it or something like it should be in the repository. It came out of some stuff I’d written and a few suggestions by Shaun McCormick in this thread started by someone else:

                http://modxcms.com/forums/index.php/topic,48794.0.html

                [edit: for the UltimateParent functionality in the old GetField, I just use this snippet in conjunction with UltimateParent.]
                  Time is what keeps everything from happening all at once.
                  • 36541
                  • 222 Posts
                  Quote from: paulmerchant at Jul 26, 2010, 01:59 PM
                  This is what I use for GetField type stuff in Revo:

                  Thanks for sharing.

                  I mentioned I think it would be a better way to extend getResources a bit, rather than recreating my snippet. getResources goes far beyond where getField would ever go. All that needs to be done to get getField type stuff is to add explicit ids to collection.
                    This is the web: the only thing you know about who will come is that you don't know who will come.
                    • 22829 ☆ A M B ☆
                    • 80 Posts
                    Quote from: gadamiak at Jul 27, 2010, 03:01 AM

                    I mentioned I think it would be a better way to extend getResources a bit, rather than recreating my snippet. getResources goes far beyond where getField would ever go. All that needs to be done to get getField type stuff is to add explicit ids to collection.

                    I’ve also had a few instances when I thought it would be great to just pass a list of resource ids to getResources. That would be a great additional feature.

                    The reason for getResourceField is because I like using simple tools for simple tasks. I didn’t feel like I needed getResources to grab a simple field value from a single resource.
                      Time is what keeps everything from happening all at once.
                      • 36541
                      • 222 Posts
                      Quote from: paulmerchant at Jul 27, 2010, 09:46 AM
                      The reason for getResourceField is because I like using simple tools for simple tasks. I didn’t feel like I needed getResources to grab a simple field value from a single resource.

                      I agree with your point. However, I do prefer not to use many tools for the same task. Especially, when one tool is a special use case of the another.

                      Moreover, the ability to get contents from arbitrary selected resource is highly demanded and useful feature and, in fact, should be included in the core itself or a core snippet, which getResources definitely is. The popularity of original getField proves it, IMO.
                        This is the web: the only thing you know about who will come is that you don't know who will come.