We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21998
    • 2 Posts
    Hello, I build a menu with getressources, and I would like to highlight the current menu item being visited by applying a class to the element.
    It was possible to do this with Ditto on Evo, but is there an equivalent for getRessources in Revo ?
    Thanks
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: ocbslim at Mar 03, 2010, 12:27 PM

      Hello, I build a menu with getressources, and I would like to highlight the current menu item being visited by applying a class to the element.
      It was possible to do this with Ditto on Evo, but is there an equivalent for getRessources in Revo ?
      Thanks
      You could use the If snippet in your tpl chunks to add the class, e.g.:
      <li[[!If? &subject=`[[+id]]` &operator=`eq` &operand=`[[*id]]` &then=` class="current"`]]><a href="[[~[[+id]]]]" title="[[+pagetitle]]">[[+longtitle]]</li>


      But in general, Wayfinder is meant for menu building and getResources (or Ditto) for summarizing content, so this is not a feature built into getResources as it is in Wayfinder.
        • 21998
        • 2 Posts
        Thanks for the help OpenGeek, wayfinder works fine, but not for weblinks. I mean if the user click on a weblink that leads to another modx document the menu item won’t be applied the class.


        EDIT :

        I attempt to adapt wayfinder hack found here => http://modxcms.com/forums/index.php/topic,28461.msg185401.html#msg185401

                
        global $modx;
        $doc = $modx->resource->get('id',$did);
        if ($doc['type'] == 'reference')
        $did = $doc['content'];



        but it does not apply the class.
          • 22303 MODX Staff
          • 10,725 Posts
          Doesn’t work for WebLinks? It works fine for WebLinks on our sites AFAIK. That hack is for the Evo version of Wayfinder and really shouldn’t apply. If there is a bug, please report it via our reporting system at http://svn.modxcms.com/jira/browse/WAYFINDER and indicate it is for the Revo release version you are using.

          Further, how could a WebLink be the current Resource in any menu since all it does is redirect the user to the indicated location? You would never be on a view where a WebLink was the current Resource.