Robert
Robert

Reputation: 592

prepend link to home in TYPO3 8.7.3

I used the following TS (TYPO3 7.6.) in my navigation:

(...)
# prepend link to home
stdWrap.prepend = TEXT
stdWrap.prepend {
    data = leveltitle:0
    typolink.parameter.data = leveluid:0

    wrap = <ul><li>|</li>
    wrap.override = <ul><li class="cur">|</li>
    wrap.override {
        if.value.data = leveluid:0
        if.equals.data = TSFE:id
    }
    typolink.parameter.data.override = leveluid:
    typolink.parameter.data.override {
        if.value.data = leveluid:0
        if.equals.data = TSFE:id        
    }
}
(...)

After upgrading to TYPO3 8.7.3 I get <li><a>Home</a></li>instead of a complete link.

The tag for the current state is fine <li class="cur">Willkommen</li>

I got the idea from this website: https://blog.reelworx.at/detail/typo3-menu-add-link-to-home/

Upvotes: 0

Views: 655

Answers (1)

Jo Hasenau
Jo Hasenau

Reputation: 2684

You should never prepend single parts of a wrap but always use a full wrap instead to avoid broken HTML structures. Additionally there is a method to detect if a page is the current page by going for a TMENU instead of a typolink. So you get all the menu states instead of using override and if.

# Full menu of two parts
10 = COA
10 {
  wrap = <ul>|</ul>
  10 = HMENU
  10 {
    special = list
    special.value.data = leveluid:0
    1 = TMENU
    1 {
      NO = 1
      NO {
        allWrap = <li>|</li>            
      }
      CUR < .NO
      CUR {
        doNotLinkIt = 1
        allWrap = <li class="cur">|</li>            
      }
    }
  }
  20 < .10
  20.special = directory
  20.1.ACT < .20.1.NO
  20.1.ACT.allWrap = <li class="act">|</li>
}

The first part provides a single link to the root page, which will change if you are on the root page itself, the second part will provide the usual menu structure of the pages below. So it changes the menu from list to directory and adds the ACT state. Should be working with any CMS version.

Upvotes: 1

Related Questions