Search code examples
typo3fluidtypo3-11.x

How does one make TYPO3 generate different output for backend users?


I would like to output additional data in most content elements (mostly fluid_styled_content) in the frontend for logged-in backend users (editing links for the CEs, additional information). The first idea was to insert additional Fluid code within <f:be.security.ifAuthenticated>. In theory this does the right thing, but the result is cached (bad: BE users might not see the additional data, others might see it). How does one work around this?

Ideas:

  1. Use different templates for BE users. How?
  2. Disable writing to and reading from the cache for BE users. How?
  3. (Automatically) Assign a FE user group to BE users, because the cache should create different entries for each FE user group. How?
  4. Render the additional output using JavaScript and get the data separately. Caching could work for all users, but complicated and would still require some way to discriminate between BE-/non-BE users. Would prefer not to implement this.

Requirements for a solution:

  1. FE caching should continue to work for users which are not logged into the BE.
  2. Caching for BE users does not necessarily have to work, but would be nice-to-have.
  3. The output does not need to differ further between users.

Solution

  • You could deactivate the page cache for logged in backend users with a TypoScript condition:

    [backend.user.isLoggedIn]
      config.no_cache = 1
    [global]
    

    That seems excessive and there should be better solutions.

    Ideas:

    • Add a cacheTag depending on BE login state (this would enable caching for all users)
    • disable caching in your content element definition's TypoScript by wrapping the FLUIDTEMPLATE in a COA_INT (see this SO post) (this would only disable caching for that FLUIDTEMPLATE)
    • Can <f:cache.disable> around the condition help? I found these to have no effect in plain content elements (FLUIDTEMPLATE), though.
    • Can <vhs:render.uncache> help?