We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I haven't looked at the code lately, but I think Wayfinder actually retrieves the entire resource for every resource in order to get the fields it needs.

    You might try creating a page with just the Wayfinder tag on it, then create a utility snippet that retrieves that page with cURL and writes the content to a chunk. Then use that chunk as your menu (running the utility snippet when things change). You would lose some of the Wayfinder styling options, but would gain a lot of speed.
      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
      • 34244
      • 51 Posts
      Bob,

      I think this is a great idea. Do you have an example of such a utility snippet that can preprocess a Wayfinder menu and place it in a chunk?

      Thanks,

      Matt
        • 3749
        • 24,544 Posts
        I'm sorry, I don't. You could look at the RefrechCache snippet, which requests pages with cURL. It doesn't do anything with them, but the page's HTML should be there in the return.

        BTW, various attempts to get Wayfinder output directly with runSnippet() have all failed. That would be a better method, but I suggested using cURL because it doesn't seem to work.



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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
          • 3749
          • 24,544 Posts
          It would look something like this (untested) -- use no template for the page:


          <?php
           $url = 'full/url/of/the/page';
          
           $ch = curl_init(); // Initialize Curl
              if ($ch === false) {
                  $return = "Failed to initialize cURL";
              }
          
              @curl_setopt($ch, CURLOPT_NOBODY, TRUE);
              @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
              @curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); // don't use a cached version of the url
          
              ignore_user_abort(true); // keep on going even if user pulls the plug
          
          curl_setopt($ch, CURLOPT_URL, $url); // tell cURL the URL
          
                  $content = curl_exec($ch); // get the page 
          
                  if (curl_errno($ch)) {
                      return 'cURL error: ' . curl_errno($ch) . " - " . curl_error($ch);
                    
                  } else  {
                      // put the content in the chunk here
                     $chunk = $modx->getObject('modChunk', 'MyChunk');
                     if ($chunk) {
                          $chunk->setContent($content);
                          $chunk->save();
                     } else {
                         return 'could not find chunk';
                     }
          
                     
               }
          



          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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