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

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 FLUID_TEMPLATE 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}.


In typoscript template for your content object FLUIDTEMPLATE:

Typoscript setup/configuration:

10 = FLUIDTEMPLATE
10 {
    variables {
        pageUid = TEXT
        pageUid.value = 114
    }
}

or using constants

Typoscript constants:

pageUid = 114

Typoscript setup/configuration:

10 = FLUIDTEMPLATE
10 {
    variables {
        pageUid = TEXT
        pageUid.value = {$pageUid}
    }
}

Then you can fetch pageUid in your Fluid HTML

<f:else>
    <li>
        <v:page.link pageUid="{pageUid}" />
    </li>
</f:else>

To use variables in a Fluid partial, make sure to pass these along, e.g. by providing _all:

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

Tags:

Typo3

Fluid