typo3fluid

TYPO3 - how to properly define constant, store it into variable and use inside of fluid template


In the Fluid template of a plugin I am working on, some things are hardcoded. For instance:

<f:page.link pageUid="114">link</f:page.link>

Since pageUid values are not the same on the test and production servers I would like to make this more dynamic.

I would like to store the pageUid in a variable and then use the variable in the Fluid template.


Solution

  • Because it is an setting do it like this:

    Constants:

    plugin.myext.settings.detailPid = 123
    

    Setup:

    plugin.myext.settings.detailPid = {$plugin.myext.settings.detailPid}
    

    Variables are for variable content. If you have the same PID using variables with TEXT or similiar is overdressed and settings are the correct way.

    Also variables are only accessable for FLUIDTEMPLATE content element, not for plugins!

    Also in your extbase controller you can access these settings by simple access $this->settings['detailPid']without to render the cObjects first.

    In your fluid you can access settings by {settings.detailPid}.