We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4310
    • 2,310 Posts
    Yes, I added it to the head area of the template instead.
    To exclude any docs I added:
    $params['excludeDocs'] = '72';

    to the plugin and it worked great.
    Again thanks.

    David
      • 7231
      • 4,205 Posts
      Hey, this is great. Thanks. 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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 13481
        • 97 Posts
        I just wanted to make an update on this issue. I think that server this site is on has some issues that make this code run slow. Or perhaps wayfinder is not optimized for menus with 1000+ items, I don’t know. Anyway, I applied ganeshXL’s solution which made the site tons faster since it didn’t have to process the menu every time, but it made saving pages really slow since that is when it processed the menu. So I decided to take the same code that ganeshXL wrote and placed it in a module. Now, by running the module manually the client can update the menu. I think this is the solution that is going to work long term.

        My Lesson Learned: Do whatever you can to talk your client out of this many menu items, there are just way too many pitfalls and drawbacks if you don’t. Have more foresight than I did smiley

        Thanks for all of your suggestions!

        James
          • 17016
          • 138 Posts
          Hi ganeshXL,
          do you know how I have to change the code to make the plugin work in revo?
          Quote from: ganeshXL at Jan 28, 2008, 04:53 PM

          $myChunk = 'testMenu'; // your chunk name
          $params['startId'] = '0';
          $params['level'] = '4';
          $html = addslashes($modx->runSnippet('Wayfinder', $params));
          $sql= "UPDATE " . $modx->getFullTableName("site_htmlsnippets") . " SET snippet='$html' WHERE name='$myChunk'";
          $result= $modx->dbQuery($sql);
          

            • 10449
            • 956 Posts
            Wow, I didn’t even remember that... 3 1/2 years pass quickly smiley

            Here’s a basic intro to Revo plugins: http://rtfm.modx.com/display/revolution20/Plugins

            But, as devtrench mentioned above, I would tend to prefer the "update manually via module" variety over my initial plugin idea.

            I guess the most elegant way (from end-user / editor perspective) would be to include an additional menu item just for that purpose near "clear cache", or on the start page dashboard.
              • 17016
              • 138 Posts
              Hi ganeshXL,

              your idea to put the wayfinder in a chunk was really very good. Our website is now much faster. The only big disadvantage is that we use an Accordion-Menue which now collapse all the time. Normally the menu should stay opened at that point of the currently activated/opened page. In our case this is solved by the wayfinder by adding for example
              <li class="first expand active">

              to the currently activated menu point.

              Do you have any idea how to solve this? Maybe we can add this class by javascript after the page-load has done.

              Another way could be to create an own menu-chunk to every single page which includes the class="first expand active" at the right point. Including such a chunk in the template would be very easy for example by a call like this:

              [[$menuchunk-[[*id]]]]


              If you renew the menu once a day like you proposed above the time for this manually started procedure wouldn´t matter.

              What do you think will be the best solution?
                • 10449
                • 956 Posts
                That’s a tough one. Do you have a working example of such a rendered HTML output, incl. the necessary JS/CSS?

                In some cases, it’s standard practise to use <body class="foo"> or <body id="foo">, to alter the appearance of certain pages / sections / menus etc. via CSS.

                Maybe the JS code of your accordion menu can be altered so it would first query the body id/class, and subsequently inject the necessary <li class="active... whatever"> bit. You could obviously work with document ids, but since you can’t have numbers as CSS class- or DIV-names, you’ll have to construct something with prefix_id.

                There’s a Wayfinder parameter / method to include ids somewhere, you’ll find it in the manual I’m sure. That could serve as a "glue" for JS to check the body-id against the menu-li-id.

                That’s really just a vague first idea... it’s almost 1AM here and my mind is really not that fresh right now.
                  • 36967
                  • 4 Posts
                  Hi ganeshXL

                  Is there anyway you could please create this plugin to work with 2.1.3.

                  If you could that would be f*#ing awsome.

                  I have resorted to leaving the wayfinder call on a hidden resource then copying and pasting the menu into a chunk so its quick.

                  Please help!!
                    • 33968
                    • 863 Posts
                    Revo version:

                    a) create a chunk. Leave it empty. Name it whatever you want, e.g. testMenu

                    b) create a plugin. Enter this:
                    $myChunk = 'testMenu';
                    $params['startId'] = '0';
                    $params['level'] = '4';
                    // additional Wayfinder params here
                    
                    $html = $modx->runSnippet('Wayfinder', $params);
                    $chunk = $modx->getObject('modChunk', array('name' => $myChunk));
                    if (!empty($chunk)) {
                        $chunk->set('snippet' => $html);
                        $chunk->save();
                    }
                    

                    c) Check the system event OnDocFormSave + save the plugin.

                    d) Change your template: Replace your Wayfinder call with your chunk:
                    [[$testMenu]]

                      • 40024
                      • 72 Posts
                      First of all:wow! You guys deserve a medal for building this!
                      I have the following two questions though:
                      1)When you say that it is better to implement this with a module,well,how can it be done this way?Could somebody post or write the necessary code?

                      2)This is best used when a snippet has to deal with a lot of document/resources,or can it be used with less resources?I mean,if there are any cons to this method when somebody has very few documents to deal with(let's say 100).