We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5628
    • 44 Posts
    Hi all
    I am using wayfinder (2.0) and want to employ it to generate a sitemap.
    In this particular instance, there are some containers/folders in the site where I want to include the parent but not its children.
    For example, say I have the following site structure

    [tt]* Projects container
    * Project 1
    * Project 2
    * Project 3
    * Links container
    * Links 1
    * Links 2
    * Links 3
    [/tt]
    Now, if I want to include the list of projects in the wayfinder call but not the list of links is this achievable with wayfinder?
    I cannot use a level restriction as that will exclude all container children.
    I don’t want to use excludeDocs if I can as some of the containers have a high-volume of children and I don’t want to be adjusting the wayfinder script everytime someone wants to add a new child. Is it possible to specify folders/containers for which their children should be ignored?
    Hope this makes sense and someone can assist.

    Cheers in advance,
    Cole
      • 7231
      • 4,205 Posts
      You can use the ’show in menu’ option to hide a page from the navigation. You can also apply a style to weblinks and hide them using css.

      Another option is to use a snippet to dynamically create the excludeDocs list based on certain criteria (like if it is a weblink).
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        If I understand correctly, you can also use phx (if it’s installed as a plugin) to do that?
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 5628
          • 44 Posts
          Quote from: coleh at Jul 04, 2008, 08:20 AM

          I am using wayfinder (2.0) and want to employ it to generate a sitemap.
          In this particular instance, there are some containers/folders in the site where I want to include the parent but not its children.
          Now, if I want to include the list of projects in the wayfinder call but not the list of links is this achievable with wayfinder?

          Have managed to provide a solution for this though did require some hacking of the Wayfinder snippet, so I thought would post here in case of interest to anyone.
          The following hack relates to version 2.0 of wayfinder.

          1. Add the following line to the $wf->_config array in the wayfinder snippet: [tt]’ignoreKids’ => isset($ignoreKids) ? $ignoreKids : 0,[/tt] (line 42):
          $wf->_config = array(
          	'id' => isset($startId) ? $startId : $modx->documentIdentifier,
          	'ignoreKids' => isset($ignoreKids) ? $ignoreKids : 0,


          2. Insert the following lines to the wayfinder.inc snippet file, replacing line 99 (currently [tt]$docInfo[’hasChildren’] = in_array($docInfo[’id’],$this->hasChildren) ? 1 : 0;[/tt]):
          $ignoreKids = $this->_config['ignoreKids'];
          $ignoreKids = explode(',',$ignoreKids);
          $docInfo['hasChildren'] = in_array($docInfo['id'],$this->hasChildren) && !in_array($docInfo['id'],$ignoreKids) ? 1 : 0;
          


          3. To ignore all children of a particular document container, when calling the Wayfinder snippet add the parameter [tt]&ignorekids=`X`[/tt] with X being a comma-separated list of those document containers whose children you want to ignore.

          For example:
          [!Wayfinder? &startId=`0` &level=`3` &ignoreKids=`75,77,90`!]

          This will include documents 75, 77, 90 in the Wayfinder results but ignore any of their children

          Have attached a zip file containing the ammended wayfinder.inc.php and wayfinder.snippet.php files.
          Hope this is of use/help to others and if there is a better/quicker/more efficient way of doing this do let me know,

          Cole
            • 21257 MODX Staff
            • 730 Posts
            Quote from: dev_cw at Jul 04, 2008, 10:58 AM

            Another option is to use a snippet to dynamically create the excludeDocs list based on certain criteria (like if it is a weblink).

            This is a great technique; I just used it to basically extend Wayfinder with Ditto’s filtering capabilities to filter some documents out of a sitemap, like so:

            [!Wayfinder?startId=`0` &ignoreHidden=`1` &excludeDocs=`[[Ditto? &parents=`0` &depth=`0` &display=`all` &filter=`template,6,1` &tpl=`@CODE [+id+],` &tplLast=`@CODE [+id+]`]]` !] 
            


            The Ditto call is generating a CSV of ids of documents that are assigned to template id 6, and the Ditto templates for generating CSV output are so simple, they can be included right in the call.
              Mike Schell
              Lead Developer, MODX Cloud
              Email: [email protected]
              GitHub: https://github.com/netProphET/
              Twitter: @mkschell