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

    I’d like to use the IncludeDocs parameter with Wayfinder to build out the primary navigation for a site, but it seems Wayfinder is set up to automatically exclude any submenus of the included documents.

    Is this the case?

    I figure that these are the main criteria for this primary navigation:

    1. All changes to navigation are implemented by changing document properties. (changing link text by changing menutitles) This way no one has to mess with code.
    2. When new child docs of items in the navigation are created, they should automatically be in the navigation.
    3. But newly created documents that aren’t child docs of documents currently in the primary nav shouldn’t automatically be inserted into the primary nav.

    So considering these criteria, I came to the solution that using includeDocs would work. No other newly created documents would be inserted into the navigation this way, unless they were child docs of documents already in the nav. I thought about just using excludeDocs to exclude stuff i don’t want in the nav, but then when new docs are created they have to be added to the wayfinder call. So I don’t want to do that.

    So it seems that if includeDocs would just build out submenus as well, that would be the best solution all around.

    Here’s the Wayfinder call I’m using:

    [!Wayfinder? &startId=`0` &level=`0` &outerTpl=`outerTpl` &innerTpl=`innerTpl` &rowTpl=`rowTpl`
     &innerRowTpl=`innerRowTpl` &firstClass=`first` &lastClass=`last` &includeDocs=`7,6,16,17,19,20`!]


    Has anyone come across this problem and found a good solution?
      • 22303 MODX Staff
      • 10,725 Posts
      Why don’t you simply uncheck the Show in Menu checkbox to prevent documents you do not want in the menu from showing up?
        • 32266
        • 8 Posts
        Ah, I forgot to mention that I have a site navigation that utilizes Wayfinder too. And all newly created docs need to show up there. So I can’t uncheck Show in Menu for those.

        UPDATE: Looks like there is an easy solution - I just found the ignoreHidden parameter that can ignore the Show in Menu setting, showing all pages anyway. This looks like a sure fix. Thanks for the nod in the right direction OpenGeek smiley

        UPDATE 2: Hmm I guess I spoke too soon. There is no setting in Modx to turn off Show in Menu by default? I thought for sure this was there.

        UPDATE 3: Okay I think it’s safe to say this is resolved. Since I can’t set all pages to be hidden from the menu by default, I edited the file "mutate_content.dynamic.php" to leave Show in Menu unchecked when a new document is created.

        I just added a isset() check on $content[’hidemenu’] before checked="checked" is inserted into the HTML, since this isn’t set yet when a new doc is being created. Finally smiley

        <input name="hidemenucheck" type="checkbox" class="checkbox" <?php echo (isset($content['hidemenu']) && $content['hidemenu']!=1) ? 'checked="checked"':''?> onclick="changestate(document.mutate.hidemenu);" />
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: wes.h at Apr 09, 2009, 08:32 AM

          UPDATE 3: Okay I think it’s safe to say this is resolved. Since I can’t set all pages to be hidden from the menu by default, I edited the file "mutate_content.dynamic.php" to leave Show in Menu unchecked when a new document is created.

          I just added a isset() check on $content[’hidemenu’] before checked="checked" is inserted into the HTML, since this isn’t set yet when a new doc is being created.
          Though this obviously will work for you, when you upgrade MODx, you will need to maintain those changes. It would be much more beneficial if you altered any add-ons to do what you wanted or created a plugin to deal with these issues on that manager page, rather than hacking it directly.
            • 32266
            • 8 Posts
            Yea I figure since I’m using 0.9.6.3 I’m good there, since I believe that’s the last legacy upgrade... however I really don’t like this hack... had I not been using Wayfinder elsewhere on the site I would have scrapped this idea.

            Anyhow, I was surprised to see that Modx doesn’t have a site setting to allow for automatic menu hiding on when new docs are created.
              • 7231
              • 4,205 Posts
              Anyhow, I was surprised to see that Modx doesn’t have a site setting to allow for automatic menu hiding on when new docs are created.
              You can do this with a plugin easily. Look at the plugins that configure the selected template for some ideas. It would be a nice default setting to have as well grin
                [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&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 32266
                • 8 Posts
                Now that I think about it... this site will probably be upgraded to Modx Rev in the future. And if that is ever automated this could cause problems. Better look into the plugin solution. Thanks guys smiley
                  • 32266
                  • 8 Posts
                  Hi Guys,

                  I’ve been looking into writing a simple plugin to auto-uncheck the ’Show in Menu’ checkbox in the New Document Form page - but the System Event that I believe I need to attach my plugin to doesn’t have any description, explanation of how to use in the Wiki. The events I think could be useful are OnCreateDocGroup and also OnDocFormPrerender, but I can’t find any info about how to use them.

                  Could you point me in the right direction?

                  UPDATE: Got it!