Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

typo3

fluid

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

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

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

I would like to store this somehow in variable and then use the variable in the fluid template.

I just dont know hot to make this and where in TYPO3.

Thanks in advance!

like image 663
Denis Milosavljevic Avatar asked Jan 31 '17 10:01

Denis Milosavljevic


1 Answers

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

like image 69
René Pflamm Avatar answered Oct 14 '22 23:10

René Pflamm