We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50722
    • 35 Posts
    Hello all,

    I'm getting zero/zilch/nothing in return from a getResources call on a completely fresh install - getResources is the only extra in place (TinyMCE aside) and I'm pretty sure I've got my getResources call etc set up correctly. I've tried the call both cached and uncached.

    There are 3 pages at root level in the document tree and they're all using the default MODX template as it stands. All pages load fine.

    Straight away after installing and testing getResources I got error logs, but there were none with the fresh install.

    I'm wondering if this is an inherent server config issue - I'm running on a TSO Host VPS/CPanel setup. I've never had any issues with TSO before but that was always on their Cloud/shared servers, never a VPS.

    I'm reaching the server via my hostfile - it's not got any domain name DNS pointing at it at this stage. I can't imagine that would affect getResources but add it for completion.

    Here's the setup:
    MODX Revolution: 2.5.7-pl (traditional)
    PHP Version: 5.6.30
    MySQL Client API version: mysqlnd 5.0.11-dev (from phpinfo file)
    Database client version: libmysql - 5.1.73 (from phpMyAdmin)
    Server version: 5.6.35 - MySQL Community Server (GPL) (from phpMyAdmin)
    Protocol version: 10
    cPanel & WHM 64.0 (build 30)

    The getResources call:
    [[getResources? &showHidden=`1` &tpl=`pagesTpl` &debug=`1`]]

    Content of pagesTpl:
    [[*pagetitle]]
    Fluffed Up Beyond All Recognition

    Here's the MODX error log (I replaced the actual server name with 'servername'):
    [2017-07-11 10:12:33] (ERROR @ /home/servername/public_html/core/cache/includes/elements/modsnippet/1.include.cache.php : 201) context for 1 is web
    [2017-07-11 10:12:33] (ERROR @ /home/servername/public_html/core/cache/includes/elements/modsnippet/1.include.cache.php : 427) 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`.`privateweb`, `modResource`.`privatemgr`, `modResource`.`content_dispo`, `modResource`.`hidemenu`, `modResource`.`class_key`, `modResource`.`context_key`, `modResource`.`content_type`, `modResource`.`uri`, `modResource`.`uri_override`, `modResource`.`hide_children_in_tree`, `modResource`.`show_in_tree`, `modResource`.`properties` FROM `modx_site_content` AS `modResource` WHERE  ( modResource.parent IN (1) AND `modResource`.`deleted` = 0 AND `modResource`.`published` = 1 )  ORDER BY publishedon DESC LIMIT 5
    

    Can anyone see anything glaringly obvious here?

    Many thanks in advance. [ed. note: powellian last edited this post 6 years, 8 months ago.]
      • 17301
      • 932 Posts
      You're not stating where you're retrieving your resources from.

      &parents=``


      or

      &resources=``


      Also in your pagesTpl you should use placeholders [[+pagetitle]] instead of [[*pagetitle]]
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 50722
        • 35 Posts
        Thanks for the reply.

        As soon as I added parents and placeholder+ instead of asterisk I got a result - thanks, daft error with omitting the placeholder. There's a bit more to it though ...

        Originally I'd used this: &parents=`[[*id]]`
        I need getResources to automate where it looks, not have to hard-code the locations.

        I need to use 1 template for generic pages spread across different categories (containers) and the getResources call needs to list pages from the same category in a sidebar. Categories like this:
        Houses/house1.html, house2.html ...
        Flats/flat1.html, flat2.html ...
        etc.

        This will be client managed and there could be new categories/containers so any hard-coding the parents=`x` location won't work in the long run.

        Should I be using something like ultimateParent in my getResources call for that?

        Hope I've written/explained this clearly!
          • 17301
          • 932 Posts
          &parents=`[[*id]]` should work. If I've understood you correctly that is..

          [ed. note: lkfranklin last edited this post 6 years, 8 months ago.]
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
            • 17301
            • 932 Posts
            If you want to list all categories then just set the parent property to the parent container with no limit. If you just to display the resources within a category then just use the original tag posted above.
              ■ email: [email protected] | ■ website: https://alienbuild.uk

              The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
              • 50722
              • 35 Posts
              Quote from: lkfranklin at Jul 11, 2017, 12:31 PM
              &parents=`[[*id]]` should work. If I've understood you correctly that is..

              For me &parents=`[[*id]]` is returning nothing, whereas if I explicitly state the container number then I get the resources returned.

              What I need is for resources in each different category (container), to have their sibling/same-category resources listed in the sidebar, but I can't specifically name the category in the snippet call as that loses automation and scalability. I thought that's where &parents=`[[*id]]` would work.

              Hope I'm explaining clearly, let me know if not
                • 50722
                • 35 Posts
                I just tried this:
                &parents=`[[@INHERIT]]`

                It's getting there, is buggy - lists all resources at all levels, but I am getting the siblings. I'll try debugging it ...
                  • 17301
                  • 932 Posts
                  I think the terminology might be throwing me a little. Category usually referers to actual categories within MODX, or to do with tagging resources. I think instead of categories you mean parents? I'm not entirely sure what you're trying to do but &parents=`[[~id]]` would only return the child resources of the document you're viewing.

                  From what I gather you want to display all parents and children within the menu?

                  --- Grand Parent
                      --- Parent 1
                          --- Child 1
                          --- Child 2
                      --- Parent 2
                          --- Child 1
                          --- Child 2
                  

                  If this is the case then you just need to set the &parent to the grandparent id and set the level to 0 to display all children and grand children resources.
                    ■ email: [email protected] | ■ website: https://alienbuild.uk

                    The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                    • 50722
                    • 35 Posts
                    Thanks for sticking with this! I'll try a clearer explanation.

                    Here's the structure:
                    Homepage (Root level)
                    Contact page (Root level)
                    --- Parent 1 (Container)
                        --- Child 1.1
                        --- Child 1.2
                        --- Child 1.3
                        --- etc ...
                    --- Parent 2 (Container)
                        --- Child 2.1
                        --- Child 2.2
                        --- Child 2.3
                        --- etc ...
                    

                    The 'Child' pages use a template with the getResources call; the getResources call should only list the pages within the same Parent Container (in a sidebar).

                    So, if you are on page 'Child 1.2', in the page sidebar you'd see listed all the pages under 'Parent 1', and only those pages, nothing from Root level or from Parent 2.
                    Or:
                    If you are on page 'Child 2.3', in the sidebar you'd see the pages under 'Parent 2', and only those pages, nothing from Root level of from Parent 1.

                    Using &parents=`[[@INHERIT]]` isn't working properly at all - it shows all Child pages, from both Parents. Weirdly it shows the Homepage at Root level but not the Contact page, also at Root level.

                    I thought @INHERIT would show only Children from the immediate Parent as the documentation states:
                    The @INHERIT binding will automatically find the corresponding value of the parent Resource and use that as its value.
                    Hope I wrote it clearer this time, please let me know if not.
                    it's doing my head in wink
                    Thanks again
                      • 17301
                      • 932 Posts
                      Ahh ok that makes more sense smiley

                      Give this a try.

                      Create a snippet called getParentID with the following code

                      <?php
                      $parentObj = $modx->resource->getOne('Parent');
                      return $parentObj->get('id');


                      Then in your call set the parent to

                      &parents=`[[getParentID]]`
                        ■ email: [email protected] | ■ website: https://alienbuild.uk

                        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.