We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36805
    • 354 Posts
    Wayfinder can only exclude a single fixed list of document ids. It would be cool if it could have more advanced filters like Ditto. Is anything like this planned? it would be more elegant than my crude solution:

    I needed a way to exclude some docs from my sitemap according to their template id. This quick utility snippet solved it for me. It uses hardcoded template ids but could be tweaked to work with parameters or different columns of the site_content table.
    <?php
    
    // snippet getExcludesSitemap
    // works with hardcoded id's in select (here template 9 and 16 are used for excluded list)
    
    $res = $modx->db->select("id", $modx->getFullTableName('site_content'), 
          "template = '9' OR template = '16'");
    
    	 $count = $modx->db->getRecordCount($res);
       if($count)
       {
    		$i = 0;
    		$output;
    		while( $row = $modx->db->getRow( $result, 'id' ) ) {
    			$output .= $row['id'];
    			$i++;
    			if ($i < $count)
    				$output .= ",";
    		}
       }
       else $output = '';
    
    return $output;
    ?>
    


    One could use it in a Wayfinder call like on a site of mine:
    [!Wayfinder? &startId=`0` &excludeDocs=`[[getExcludesSitemap]]` &ignoreHidden=`1`!]
    
      • 22427
      • 793 Posts
      You could try to use Ditto to create a comma separated list of the IDs you want to be excluded. Then write a chunk containing the Ditto call and hand it over to the [tt]&excludeDocs[/tt] parameter.
        • 36805
        • 354 Posts
        Quote from: ottogal at Jul 26, 2011, 08:54 PM

        You could try to use Ditto to create a comma separated list of the IDs you want to be excluded. Then write a chunk containing the Ditto call and hand it over to the [tt]&excludeDocs[/tt] parameter.
        That’s a smart trick indeed. I did give Ditto a try before because of the filters. I couldn’t get proper indention though. Ditto by itself doesn’t generate nested lists. Seems I was almost done already, with your idea this would work.

        I know I’m not the only one why needs this at times. I’ve seen tedious workarounds on the forums with special show/hide toggling tv’s. So a Wayfinder filter out of the box would be great.
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          I’d second that request.... but Wayfinder needs more than just that. Use of the &excludeDocs parameter is very limited. What if you want only the CHILDREN of a series of folders. If you exclude the parent, you end up excluding the children. E.g. imagine page ids 1,2,3 have children that you want to see. Including the following argument ensures that you will never see the children:

          &excludeDocs=`1,2,3`


          The cheap workaround might be to use a custom template tpl for parentRowTpl...
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            Ok, here’s what I figured out if you want to only display the grandchildren:

            You’re Wayfinder call can look something like this (note that it is sandwhiched inbetween the ul tags):
            <ul>
            [[!Wayfinder? &startId=`123` &outerTpl=`omit_parent` &parentRowTpl=`omit_parent` &firstClass=``]]
            </ul>
            


            Then you have a chunk named omit_parent with only the following:
            [[+wf.wrapper]]


            The result here will be to skip the parent folders and only list the grandchildren... setting the firstClass parameter prevents each list item from having the same CSS class, but this may screw you up if you actually NEED to have the first menu item have a distinct class.

            OR... see how getResources can be used to do this same thing via its hideContainers parameter, e.g.:
            [[!getResources? 
              &parents=`34,35`
              &hideContainers=`1`
              &tpl=`latestPostsTpl`
              &limit=`5`
              &sortby=`publishedon`
            ]]

            See http://rtfm.modx.com/display/revolution20/Creating+a+Blog+in+MODx+Revolution#CreatingaBloginMODxRevolution-Addinga%22LatestPosts%22widget