Search code examples
typo3typoscriptfluidtypo3-8.xfelogin

TYPO3 8.7 - how to hide elements in navigation header before login with EXT:felogin?


I can't find a solution for a problem I have with a TYPO3 Fluid template.

In the navigation header template I have a search form and a logout link.

<div class="suche">
  <f:form action="search" method="post" controller="Search" extensionName="indexedsearch" pageUid="61" pluginName="Pi2">
    <f:form.textfield name="search[sword]" value="{sword}" class="quicksearch-sword" placeholder="search" />
    <button type="submit" name="search[submitButton]" class="btn">
      <i class="glyphicon glyphicon-search"></i>
    </button>
  </f:form>
  <p>
    <div class="logout">
      <f:link.page pageUid="1" additionalParams="{logintype:'logout'}">Logout</f:link.page>
    </div>
  </p>
</div>

How can I tell the page, that these two elements should also hide till the user is logged in with EXT:felogin?

The template is included into the default page template in this way:

<f:render partial="Navigation/Main" arguments="{_all}" />

I guess a simple display:none/show from the two divs would be enough, but I have no idea how to do this. (I must admit I'm not the biggest expert in TypoScript).

Any advice would be really helpful and appreciated.


Solution

  • You can use the <f:security.ifAuthenticated> view helper. More you can see here:

    https://docs.typo3.org/other/typo3/view-helper-reference/8.7/en-us/typo3/fluid/TYPO3_8-7/Security/IfAuthenticated.html

    Example:

    <f:security.ifAuthenticated>
      <f:then>
         shown when a user logged in
      </f:then>
      <f:else>
         shown when a user is not logged in
      </f:else>
    </f:security.ifAuthenticated>