Zum Inhalt springen

Use TypoScript to check whether a user is logged into the backend

TYPO3 Version:10 LTS9 LTS

A TypoScript condition can be used to check whether a user is logged into the backend. Depending on this, the output in the frontend can be changed, for example.

Application example

A website is still under development or is being revised, but is already on a server on the Internet. Visitors who call up the domain should not see the unfinished website, however, but rather an informational text or a graphic.

Users who log in to the backend should of course see the "real" website and not just the "construction site notice".

Provided that the normal PAGE object has been defined "as usual" and the page.10 object is the FLUIDTEMPLATE, this would work with the following code block in the TypoScript setup.

[getTSFE() && getTSFE().isBackendUserLoggedIn() == false]
  page.10 >

  page.10 = TEXT
  page.10.value = <h1>A new website is created here</h1>
[END]

In this example, only a simple text is output as the H1 heading.

Instead, you could also use a graphic that is located below fileadmin/ or in a site package. In the following example, the graphic is displayed horizontally and vertically centered on the screen using CSS. The values for width and height must be adjusted according to the graphic used. margin-left and margin-top receive 50% of the width and height of the image.

[getTSFE() && getTSFE().isBackendUserLoggedIn() == false]
  page.10 >

  page.10 = IMAGE
  page.10 {
    file = EXT:myextension/Resources/Public/Images/new-website.png
    wrap = <div style="width:800px;height:175px;position:absolute;top:50%;left:50%;margin-left:-400px;margin-top:-87px;">|</div>
  }
[END]

Both examples are valid as of TYPO3 9 LTS, as the new syntax for conditions is used here.

Updated: 09.04.2025