We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37163
    • 6 Posts
    I am new to MODX Revolution but must say that I really like it. I have a Wayfinder problem but am not sure if this is an error on my part.

    Using Wayfinder to generate a menu, If I have 4 document resources in my menu tree:

    Home (1)
    About Us (2)
    Our Services (3)
    Contact Us (4)

    If one of these resources, 'About Us' (2), is assigned to a 'Members only' Resource Group (that an anonymous user does not have access to) Wayfinder stops outputting any resources that fall below it in the tree, even though the other resources should be accessible to the anonymous user.

    In the resulting menu an anonymous user will only see the first resource:

    Home

    If I remove the 'About Us' page from the 'Members only' Resource Group, then the entire menu tree displays for as expected for the anonymous user...

    My snippet call is:

    [[!Wayfinder? &startId=`0` &cacheResults=`0` &sortBy=`menuindex`]]


    Not sure if I am doing anything wrong here maybe regarding security set-up - is anyone able to help?
      • 32316
      • 387 Posts
      whistlemaker Reply #2, 15 years ago
      try adding this to the call
      &level=`1`

      Of course if you have a multi-level menu it will now have only one level - try it anyway!

      I had the same problem after updating to the latest version of wayfinder (I created a thread, but can't quickly find it right now)
      If the &level=`1` "fixes" it then it would seem to be a bug - I too had a resource with limited viewing privileges.

      To fix you could also install the previous version of Wayfinder - I suspect it would work.
        • 37163
        • 6 Posts
        Thanks - I tried adding &level=`1` to the call but unfortunately the result is the same.

        As suggested I'll try installing previous version(s) of Wayfinder and see if the output changes.
          • 32316
          • 387 Posts
          whistlemaker Reply #4, 15 years ago
          Since on my site the page with restricted access is a child page I think perhaps by restricting my menu to the parents the bug does not occur.
            • 37163
            • 6 Posts
            Having a look at the wayfinder.class.php file I'm fairly sure the issue is related to the result loop in the 'getData()' function. I think the loop fails at the point where if encounters a resource object that it does not have access to.

            Before the loop, if you execute the initial SQL statement generated by the getData() function like this:

            $sql = $c->toSQL();
            $stmt = $this->modx->prepare($sql);
            $stmt->execute(); 
            $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
            $result = array();
            


            and then generate create new modResource objects from the SQL results e.g:

            foreach ($results as $row => $arr)  {
            	$obj = $this->modx->newObject('modResource', $arr);
            	$obj->set('id',$arr['id']);
            	$result[] = $obj;
            }
            


            the menu output (for a single or multi level menu) is not truncated and includes all the resources that should be accessible to an anonymous user as well as excluding all those that the user should not be able to access.
              • 37163
              • 6 Posts
              Right - sorry about that convoluted post above - looked at this again this morning and have found that if I change line 592 of 'wayfinder.class.php' from:

              $result = $this->modx->getIterator('modResource', $c)


              to

              $result = $this->modx->getCollection('modResource', $c);


              it fixes my menu.

              Sorry am new to MODX so I can't explain why the first method 'getIterator' fails and the second 'getCollection' works. [ed. note: spiltmilk last edited this post 14 years, 11 months ago.]
                • 28215
                • 4,149 Posts
                  shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                  • 32316
                  • 387 Posts
                  Changing line 592 as detailed above fixed my menu problems.