typoscripttypo3-6.2.xtypolink

TYPO3 Menu creates two anchor per link


The following TypoScript creates two anchor tags per li tag.

5 = HMENU
5 {
   wrap = <ul class="menu clearfix">|</ul>
   special = directory
   special.value = {$supportfolder}
   1 = TMENU
   1 {
     noBlur=1
     NO.ATagParams = title="{field:title}"
     NO.ATagParams.insertData = 1
     NO.allWrap = <li>|</li>
     NO.stdWrap.cObject = CASE
     NO.stdWrap.cObject {
       key.field = doktype
       1 = TEXT
       1 {
         typolink.parameter.field = uid
         field = title
         stdWrap.htmlSpecialChars = 1
       }
       # pagetype shortcut
       4 = TEXT
       4 {
         field = title
         typolink.parameter.field = shortcut
       }
       # page typo3 external url
       3=COA
       3 {
         # Textblock für HTTP-Links (Wert 1)
         10 = TEXT
         10 {
           field = title
           typolink.parameter.data >
           typolink.parameter.dataWrap = http://{field:url}
           stdWrap.htmlSpecialChars = 1
           if {
             value=1
             equals.field=urltype
           }
         }
         # Textblock für HTTPS-Links (Wert 4)
         20 < .10
         20 {
           typolink.parameter.dataWrap = https://{field:url}
           if.value = 4
         }
       }
     }
     ACT < .NO
     ACT = 1
   }
 }

The HTML result is:

<li>
   <a href="/kontakt.htm" title="Kontakt"></a>
   <a href="https://www.google.de" target="_top">Kontakt</a>
</li>

The reason for building the menu with cObject wrap is, that TYPO3 doesn't output external links when the page type is actually an external link. Instead it shows an internal link to the page, which then redirects to the external link.

And with a simple typolink it doesn't add the url scheme to the link. Thats why I came up with this solution.

The Question is: How to get rid of the first tag, which is senseless and wrong. :-)


Solution

  • Try to use doNotLinkIt = 1 in NO