Search code examples
typo3typo3-6.2.x

TYPO3 - Link to external URL redirect


I'm using TYPO3 v6.2 and inside the footer I have links to my social networks :

enter image description here

As you can see, it is "Link to external URL".

Problem: TYPO3 creates new URL www.mycompany.com/twitter and then redirects to www.twitter.com/mycompany with a 303. How to avoid this behavior?


Solution

  • In 6.2 you need to do the immediate rendering in the menu by yourself:
    For each page with type "external URL" (doktype == 3) you need to do a special handling.

    NO {
        :
        your default configuration
        :
        // special handling for 'external URL' 
        doNotLinkIt = 1
        doNotLinkIt.if {
            equals.field = doktype
            value = 3
        }
        stdWrap.cObject = TEXT
        stdWrap.cObject {
            if {
                equals.field = doktype
                value = 3
            }
            field = navtitle // title
            typolink {
                parameter.field = url
                extTarget.field = target
            }
        }
    }
    

    If you also want special handling for shortcuts you better use a CASE object with key.field = doktype

    NO {
        :
        std handling (wrap)
        : 
    
        // don't do the std link:
        doNotLinkIt = 1
        // but link it yourself:
        stdWrap.cObject = CASE
        stdWrap.cObject {
            key.field = doktype
    
            // normal pages:      
            default = TEXT
            default {
                field = navtitle // title
                typolink.parameter.field = uid
            }
    
            // shortcut
            4 < .default
            4.typolink.parameter.field = shortcut
    
            // external url
            3 < .default
            3.typolink.parameter.field = url
            3.typolink.extTarget.field = target
        }
    }