문제

In my T3 template setup I've a very simple horizontal menu like this:

lib.tmenu = HMENU
lib.tmenu{
    # first level
  1 = TMENU
  1.noBlur = 1
  1.wrap = <ul>|</ul>
  1{
    NO{
      allWrap.insertData = 1
      allWrap = <li id="nav{field:title}">|</li>
    }
    ACT=1
    ACT{
      allWrap.insertData = 1
      allWrap = <li id="nav{field:title}">|</li>
    }
    CUR=1
    CUR{
      allWrap.insertData = 1
      allWrap = <li class="active" id="nav{field:title}">|</li>
    }
  }
}

The nav{field:title} is correctly rendered eg. as navPage1 (for CSS matter). I want to show only the first level of the menu:

enter image description here

When I browse only the first level of the menu everything works fine, but as I browse a sublevel of a main page I (obviously) lose the CUR status of the parent page (eg. when I select Subpage2_2 the "Page2" is gray and not red).

How can I force the detection of the CUR parent page on a subpage selected in order to show class="active" on the "li" tag?

도움이 되었습니까?

해결책

Your TS has some errors (ul not closing and one bracket missing for NO state).

Just set the active class with the ACT menu state, which is for the menustate of menuitems at rootlevel.

lib.menu = HMENU
lib.menu{
  1 = TMENU
  1.noBlur = 1
  1.wrap = <ul>|</ul>
  1.NO {
    allWrap.insertData = 1     
    allWrap = <li id="nav{field:title}">|</li>
  }
  1.ACT=1    
  1.ACT{    
    allWrap.insertData = 1      
    allWrap = <li class="active" id="nav{field:title}">|</li> 
  }
}

Reference for item states.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top