We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26436
    • 19 Posts
    I am a huge fan of open source and know that without the willingness of people to share their code, I would still know next to nothing. As such, I feel that it is important to give back to the community that has given so much.
    Although it is a very minor contribution, I hope that someone else can find my modification to the wayfinder snippet useful.

    Situation: You have a document that is mapped to a particular document group and webuser group, but still want the navigation to show this document.

    Example: You have a user directory that is only available to registered (and logged in) users, but you want the navigation to this directory to remain visible to everyone in hopes to entice people to create an account. So you create a webuser group called "Registered users" and map this user group to a document group you created called "Registered Users Only". Next you check the "Registered Users Only" box under documents group section in the User Directory document you created.

    Problem: You view your site as an anonymous visitor and notice that the navigation button does not show in the menu. You decide to include the includeDocs parameter to the wayfinder snippet call but it still does not include the document.

    Reason: Everything is working like it should. By default the wayfinder snippet only includes documents that a particular user has access to, as it should. Also, the includeDocs parameter only includes documents that you specify AND that are accessible by a particular user, as it should.
      • 26436
      • 19 Posts
      Solution: add a new parameter to the snippet and modify the wayfinder.inc.php to include private documents.

      In the wayfinder snippet add the following includePrivates parameter: (I added this below the bottom of the $wf->config array at line 61 below the ’displayStart’ line and before the closing of the array)

       'includePrivates' => isset($includePrivates) ? $includePrivates : 0,


      Next open the wayfinder.inc.php file in the assets/snippets/wayfinder folder and goto line 350 it should look something like this

      $access = ($modx->isFrontend() ? "sc.privateweb=0" : "1='{$_SESSION['mgrRole']}' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})");
        • 26436
        • 19 Posts
        Comment out this line and add the following just below the newly commented line.
        $access = ($modx->isFrontend() ? "sc.privateweb=0 OR sc.id IN ({$this->_config['includePrivates']})" : 1='{$_SESSION['mgrRole']}' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})");
          • 26436
          • 19 Posts
          Now all that is left is to add the parameter to the wayfinder snippet call like so:
          [[Wayfinder?startId=`0` &includePrivates=`60` &outerTpl=`mh.OuterTpl` &innerTpl=`mh.InnerTpl`rowTpl=`mh.RowTpl` &innerRowTpl=`mh.InnerRowTpl` &firstClass=`first` &hereClass=``]] 
            • 26436
            • 19 Posts
            The definition of this parameter is as follows
            &includePrivates
            default: 0
            values: [ comma-delimited list of document ids ]
            description: Acts as a filter and will allow the output of private documents specified in this parameter. The startId is still required.