We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17016
    • 138 Posts
    Can anybody help me to transfer these five code-lines from evo to revo 2.1.1?

    $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'";


    These five code-lines were introduced by ganeshXL in this thread as a plugin for making wayfinder faster:
    http://modxcms.com/forums/index.php/topic,22068.msg136560.html#msg136560

    Unfortunately I am not experienced in evo, therefore I need a little help at this point.

    Can anybody help me to transfer this five code-lines? Would be great!!

    Letti
      • 33968
      • 863 Posts
      Untested but see how this goes:
      <?php
      $params['startId'] = '0';
      $params['level'] = '4';
      $html = addslashes($modx->runSnippet('Wayfinder', $params));
      $chunk = $modx->getObject('modChunk', array('name' => 'testMenu'));
      if ($chunk) {
          $chunk->setContent($html);
          $chunk->save();
      }
      


      It doesn’t actually make Wayfinder faster, but instead runs Wayfinder when you save a document and saves the updated menu markup to a chunk. That means you never run Wayfinder in the front end and load only the plain menu html.
        • 17016
        • 138 Posts
        Hi lucas,
        thanks for your help. At the moment it still don´t work. On saving a document the saving-process hangs up.

        Beside this I am meanwhile not convinced if this plugin will really help us because in our case the menu has to be a little different on every page because the menu-item which is opened should be marked like it is done in wayfinder automatically for each site...

        Nevertheless do you have any idea what could be the reason for the hanging up of the plugin above?
          • 3749
          • 24,544 Posts
          Did you connect the plugin to OnDocFormSave?

          I don’t see any reason it wouldn’t work as written, though it might take a little while to execute. The only thing that comes to mind is mod_security: http://wiki.modxcms.com/index.php/What_is_mod_security_and_how_does_it_affect_me
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 33968
            • 863 Posts
            Just tested quickly and there’s something up with this line:
            $html = addslashes($modx->runSnippet('Wayfinder', $params));
            


            Saving to the chunk works fine with that commented out. Haven’t got time to look at it now but will try again later...
              • 3749
              • 24,544 Posts
              Try this:
              $html = $modx->runSnippet('Wayfinder', $params);
              
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 17016
                • 138 Posts
                Thanks for the help.

                Unfortunately it still doesn`t work. For testing I tried this in a snippet, but there was no wayfinder output on the site from which I called the snippet:

                <?php
                $params['startId'] = '0';
                $params['level'] = '3';
                $modx->runSnippet('Wayfinder'), $params);
                


                Is this kind of setting parameters still OK in Revolution?
                $params[’startId’] = ’0’;
                  • 33968
                  • 863 Posts
                  I think the problem is that Wayfinder is trying to get a reference to the ’current’ page so it can set the active menu items. But seeing as you’re calling it from within the manager it’s breaking at that point. I think the code is significantly different from the Evo version.

                  Beside this I am meanwhile not convinced if this plugin will really help us because in our case the menu has to be a little different on every page because the menu-item which is opened should be marked like it is done in wayfinder automatically for each site...
                  That’s true, it’s not going to help you at all if it needs to be different on every page.

                  How slow is your menu loading? Are you calling it cached?
                    • 17016
                    • 138 Posts
                    Quote from: lucas at Jul 04, 2011, 02:13 PM

                    How slow is your menu loading? Are you calling it cached?

                    Wayfinder is called cached. For the first time the executioner-snippet says 2.5 seconds. For the second time 1.3 seconds.

                      • 17016
                      • 138 Posts
                      Quote from: lucas at Jul 04, 2011, 02:13 PM

                      Beside this I am meanwhile not convinced if this plugin will really help us because in our case the menu has to be a little different on every page because the menu-item which is opened should be marked like it is done in wayfinder automatically for each site...
                      That’s true, it’s not going to help you at all if it needs to be different on every page.
                      I think we would need a own chunk with the menu in it for every page. All these chunks have to be updated on saving / creating a new resource. I think such automatically created chunks shouldn´t be too difficult to implement but at the moment I am not sure how to realize this.

                      Maybe somebody has an idea how to do this...