We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19534
    • 183 Posts
    Hey!

    I’ve the following site structure:


    • Products
      [list]
      [li]Product1
    • Product2
    • Product3
    • Product4
    [/li]
    [li]Category1

    • Product1 (Symlink to Products/Product1)
    • Product4 (Symlink to Products/Product4)
    [/li]
    [li]Category2

    • Product2 (Symlink to Products/Product2)
    • Product4 (Symlink to Products/Product4)
    [/li]
    [li]...[/li]
    [/list]

    I’m using a very simple Wayfinder call to build my navigation. When a vistor clicks on Category2/Product2 the browsers url points to http://host/category2/product2.html but wayfinder marks Products/Product2 as the active page.
    How can I get Wayfinder to mark the resource which is assigned to the url (Category2/Product2) as active?
      Add-On to easily manage your multilingual sites: Babel
      • 19534
      • 183 Posts
      Hi!

      I wrote a small wrapper snippet for Wayfinder which solves my problem:

      SymlinkAwareWayfinder
      <?php
      // works with friendly alias on
      $originalResource = $modx->resource;
      $requestedResourceId = $modx->request->getResourceIdentifier('alias');
      $requestedResource = $modx->request->getResource('alias', $requestedResourceId);
      $modx->resource = $requestedResource;
      $output = $modx->runSnippet('Wayfinder', $scriptProperties);
      $modx->resource = $originalResource;
      return $output;
      


      I appreate some comments from the people how are familiar with the core code: Am I using the methods correctly and is this solution performant? I still have the feeling that this code is not that clean...

      Maybe it would be better to check whether the request is a direct request or a forwarded request initiated by a call of sendForward() (How can I do this?). Then the $modx->resource will only be set if the current request is a forwarded request.
        Add-On to easily manage your multilingual sites: Babel
        • 7914
        • 137 Posts
        Hi Jakob, I think I am running into the same thing. My url reflects the correct path, but my nav thinks I am in the other directory. (As does my secondary nav)
        However, I don’t understand how you connected your wrapper.

        Thank you!
          • 22303 MODX Staff
          • 10,725 Posts
          Have you upgraded to 2.0.5? The behavior of Symlinks has changed and it should resolve the issues folks have had with navigation not appearing properly, as it now keeps the id of the SymLink resource rather than the Resource being forwarded to.
            • 7914
            • 137 Posts
            I have not, but will give it a try. Thank you!
              • 560
              • 0 Posts
              I think I’m having a similar issue. I have a "sponsorship" link under two top level navigation items so I used a symlink for the second. THe problem is that the wayfinder is using the same menu for both in our sidebar. I have v. 2.1.1 of MODX and v. 2.3.1 of Wayfinder. Any way to fix this? Or will some kind of custom coding be necessary?
                • 560
                • 0 Posts
                I found this bug report, and tried the fix. It didn’t work for me, but perhaps it will for you: http://bugs.modx.com/issues/3039
                  • 22303 MODX Staff
                  • 10,725 Posts
                  The "fix" has been in the core since 2.0.6-pl was released; you should not have to apply anything. My SymLinks are generating links as expected.