Search code examples
typo3felogin

How to show username in frontend in TYPO3 10?


In TYPO3 9 I managed to display the current username in a FLUID-template with the following Typoscript:

[loginUser=*]
    temp.username = TEXT
    temp.username {
        insertData = 1
        value = {TSFE:fe_user|user|username}
        noTrimWrap = | ||
    }
[global]

In TYPO3 10.4 this is not working anymore. Any idea how to display the current user? Many thanks! Urs


Solution

  • In Typo3 V10, you have to use the Context API to retrieve data from global objects, try this :

    [frontend.user.isLoggedIn]
    temp.username = TEXT
    temp.username.data = TSFE:fe_user|user|name
    temp.username.wrap = |
    [global]
    

    Have a look at those links :

    https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/DataTypes/Index.html https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Context/Index.html#context-api

    Florian