Search code examples
menutypo3shortcuttyposcript

TYPO3 create menu shortcut linking to first child menu if exist's


I have the following problem under TYPO3:

I want to link to the first child of the sub menu if there are any in level 0 of the menu.

For Example, clicking on products should bring us to screwdrivers, not to the products page, which is and should be empty.

-home (id=1)
-products (id=2)
--screwdrivers (id=3)
--cables (id=4)
-about (id=5)
-impress (id=6)

I have a simple 3 leveled menu, created by Typoscript:

temp.menu_1 = HMENU
temp.menu_1 {
  1 = TMENU
  1 {
    #expAll =1
    wrap = <ul id="nav1">|</ul>
    noBlur = 1


    NO = 1
    NO {
      wrapItemAndSub = <li>|</li>
      stdWrap.htmlSpecialChars = 1
      ATagTitle.field = title
    }
    ACT <.NO
    ACT {
      wrapItemAndSub = <li id="nav1act">|</li>
    }

  }

  2 < .1
  2 {
    wrap = <ul id="nav2">|</ul>
    ACT.wrapItemAndSub = <li id="nav2act">|</li>
  }

  3 < .2
  3 {
    wrap = <ul id="nav3">|</ul>
    ACT.wrapItemAndSub = <li id="nav3act">|</li>
  }
}

I already found some nice Typoscript replacing a id dynamically but do not understand, how to combine it, or if there is a much simpler solution, I guess.

sample taken from here: (German only) http://www.auxnet.de/blog/blog-post/2011/01/15/typo3-einzelnen-menue-link-durch-anderen-link-ersetzen.html

Typoscript: replacing a id in the menu:

lib.myFooterNav = HMENU
lib.myFooterNav.special = directory
lib.myFooterNav.special.value = 44
lib.myFooterNav.wrap = <div class="hlist"><ul>|</ul></div>
lib.myFooterNav.1 = TMENU
lib.myFooterNav.1 {
  NO.allWrap = <li>|</li>
  NO.doNotLinkIt.stdWrap.override = 1
  NO.doNotLinkIt.stdWrap.if {
    equals.field = uid
    value = 48
  }
  NO.before.stdWrap.cObject = TEXT
  NO.before.stdWrap.cObject {
   data = getIndpEnv:REQUEST_URI
   wrap = !!<=|?===>
  }
  NO.before.stdWrap.if {
    equals.field = uid
    value = 48
  }
  NO.after = </a>
  NO.after.stdWrap.if {
    equals.field = uid
    value = 48
  }
  ACT.allWrap = <li>|</li>
  ACT.ATagParams = class="active"
  ACT = 1
}

Solution

  • I think you can just make the product page a shortcut of the screwdriver page and leave the typoscript untouch.