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.0-pl by opengeek.

    Brief Description:

    getResources 1.2.0-pl (September 25, 2010)

    • Fix error when &parents is not set
    • Allow empty &sortby
    • Add ability to sort by a single Template Variable value (or default value)
      • 27985
      • 54 Posts
      What other keys can be matched in the freeform WHERE variable?

      Thanks,
      S
        MODx 2.0.6
        PHP 5.3.3
        MySQL 5.1.50
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: someone at Oct 01, 2010, 02:07 PM

        What other keys can be matched in the freeform WHERE variable?
        Any of the Resource Fields.
          • 27985
          • 54 Posts
          Should this work?:

          [[!getResources? &where=`{"id:=":1}`]]

          These work:

          [[!getResources? &where=`{"parent:=":1}`]]
          [[!getResources? &where=`{"template:=":1}`]]

          Thanks!
            MODx 2.0.6
            PHP 5.3.3
            MySQL 5.1.50
            • 27985
            • 54 Posts
            Also:

            It would be cool if getResources would return the parent resource when using &parents or matching parent in &where.

            Would be nice if this was just another switch, i.e. ’returnParent’.

            (What I am trying to do is return a list of nav links by id. I guess this could just be done using simple links....) Perhaps I’m using the wrong tool for the job.
              MODx 2.0.6
              PHP 5.3.3
              MySQL 5.1.50
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: someone at Oct 01, 2010, 02:44 PM

              (What I am trying to do is return a list of nav links by id. I guess this could just be done using simple links....) Perhaps I’m using the wrong tool for the job.
              Navigation should be done with Wayfinder IMO.

              Quote from: someone at Oct 01, 2010, 02:40 PM

              Should this work?:
              [[!getResources? &where=`{"id:=":1}`]]
              Probably not, since primary selection already occurs via the &parents OR &resources properties.
                • 27985
                • 54 Posts
                Interesting, ’&resources’ is not listed as a variable on http://rtfm.modx.com/display/ADDON/getResources but it does indeed work, even with a comma delimited list. Cool.

                Also interesting is that I have the following site struct:

                -home(1)
                -sub page(2)
                -home2(3)
                -home3(4)

                and if i do:
                [[!getResources]]
                or
                [[!getResources? &resources=`3,4`]]

                It returns only resource #2

                But if I do:

                [[!getResources? &parents=`5000` &resources=`3,4`]]

                I get 3 and 4.

                Do you know why the first examples are returning resource 2?
                  MODx 2.0.6
                  PHP 5.3.3
                  MySQL 5.1.50
                  • 27985
                  • 54 Posts
                  btw, i’m going to use
                  [[!getResources? &parents=`-1` &resources=`1,4,3,5` &tpl=`getResources.li`]]
                  as &parents=`null` and &parents=`none` was failing laugh

                  As far as using wayfinder, it doesn’t seem to really account for non tree-based queries. I see this as a major value that getResources provides. Without that, getResources is more of a me-too to wayfinder. I know there is more going on here, but that was my initial newbie-to-modx impression.
                    MODx 2.0.6
                    PHP 5.3.3
                    MySQL 5.1.50
                    • 27985
                    • 54 Posts
                    Anyways, here’s what I came up with, a simple nav menu using ’getResources’ and ’if’:

                    In the template:

                    <ul id="mainNav">
                    [[!getResources? &parents=`-1` &resources=`1,4,3,5` &tpl=`getResources.li`]]
                    </ul>

                    Contents of getResources.li chunk:

                    <li>[[!If?
                    &subject=`[[+id]]`
                    &operator=`EQ`
                    &operand=`[[*id]]`
                    &else=`<a href="[[~[[+id]]]]" title="[[+pagetitle]]">[[+pagetitle]]</a>`
                    &then=`[[+pagetitle]]`]]
                    </li>
                      MODx 2.0.6
                      PHP 5.3.3
                      MySQL 5.1.50
                      • 10323
                      • 35 Posts
                      I’m having an issue with getResources 1.2.0-pl not outputting anything (with parents other than `0`). Others have reported a similar issue.

                      My getResources call: [[!getResources? &parents=`[[*id]]` &debug=`1`]]

                      Running MODx Revolution 2.0.3-pl, getResources 1.2.0-pl, Apache/2.0.46 (CentOS), PHP 5.2.6 (executed via FastCGI), MySQL client API 4.1.24.

                      It seems strange to me that there is `modResource`.`parent` IN (1,26,10,24) in the query, when there should only be one parent (1)? (1 is the id of the resource - a container - that uses the template containing the call. 26,10 and 24 are children inside that container.)

                      The full debug output:

                      [2010-10-06 21:20:03] (ERROR @ /index.php) SELECT `modResource`.`id`, `modResource`.`type`, `modResource`.`contentType`, `modResource`.`pagetitle`, `modResource`.`longtitle`, `modResource`.`description`, `modResource`.`alias`, `modResource`.`link_attributes`, `modResource`.`published`, `modResource`.`pub_date`, `modResource`.`unpub_date`, `modResource`.`parent`, `modResource`.`isfolder`, `modResource`.`introtext`, `modResource`.`richtext`, `modResource`.`template`, `modResource`.`menuindex`, `modResource`.`searchable`, `modResource`.`cacheable`, `modResource`.`createdby`, `modResource`.`createdon`, `modResource`.`editedby`, `modResource`.`editedon`, `modResource`.`deleted`, `modResource`.`deletedon`, `modResource`.`deletedby`, `modResource`.`publishedon`, `modResource`.`publishedby`, `modResource`.`menutitle`, `modResource`.`donthit`, `modResource`.`haskeywords`, `modResource`.`hasmetatags`, `modResource`.`privateweb`, `modResource`.`privatemgr`, `modResource`.`content_dispo`, `modResource`.`hidemenu`, `modResource`.`class_key`, `modResource`.`context_key`, `modResource`.`content_type` FROM `site_content` AS `modResource` WHERE ( ( `modResource`.`parent` IN (1,26,10,24) AND (`modResource`.`context_key` IN (’web’) OR EXISTS(SELECT 1 FROM `context_resource` `ctx` WHERE `ctx`.`resource` = `modResource`.`id` AND `ctx`.`context_key` IN (’web’))) ) AND `modResource`.`deleted` = ’0’ AND `modResource`.`published` = ’1’ AND `modResource`.`hidemenu` = ’0’ ) ORDER BY publishedon DESC LIMIT 5

                      Any idea what might be wrong?