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

    I would like to be able to assign a "current" class to the currently active <ul> so that I would be able to target all sibling <li>’s to the currently active one. I really can’t figure out how to do this with only css, and I don’t want to use js.

    What I mean is that the <ul> that contains the <li> with the &selfClass gets a &currentUlClass. I guess it would work if the sibling <li>’s got a similar class instead, but I think the <ul> class would be better.

    If anyone’s got another way to solve my problem I would appreciate a push in the right direction.
      • 7231
      • 4,205 Posts
      By default WF will assign a ’active’ class to the active menu item and it’s parents. You can alter this behavior by changing the &hereClass=`current` so that instead of active it will be current.

      If you have custom tpl chunks you need to add the [+wf.classes+] placeholder where you want the class information to show up. You could also edit the innerTpl to use a custom class as well by adding it to the tpl chunk. Here is an example of a outerTpl with the classes placeholder:
      <ul[+wf.classes+]>
      	[+wf.wrapper+]
      </ul>


      Check out WF parameters to see all the options that you have:
      http://www.muddydogpaws.com/development/wayfinder/parameters.html
        [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&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 28338
        • 46 Posts
        But the active class applies to parents and grandparents and so on all the way to the top. I want something that works exactly as the &selfClass but for <ul>’s. It should apply only to the <ul> that contains the currently active <li> and nothing else.
          • 28338
          • 46 Posts
          I kind of fixed it with an ugly hack. I put this code:

          if(in_array($modx->documentIdentifier, $modx->getChildIds($docInfo['parent'], 1))) {
          	$classNames .= ' current_ul';
          }
          
          


          Between the lines

          $classNames = $this->setItemClass($wrapperClass);


          and

          if ($classNames) $useClass = ' class="' . $classNames . '"';


          in the function buildSubMenu() in wayfinder.inc.php. It’s around line 123.

          It’s nothing fancy, but it seems to work.

            • 7231
            • 4,205 Posts
            Glad you got it working.
              [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&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]