3

I'm using fluidcontent and I would like to render a plugin in a content-element. Therefore I created the following COA:

form = COA
form {
     15 < tt_content.list.20.extname_form
     15.settings.id = |
}

This object is getting rendered in the fluid template with the cOject viewhelper.

<f:cObject typoscriptObjectPath="form" data="testId" />

The rendering process works fine.

The problem is that I can't access the data variable inside the COA object. In the form template the content of the variable settings.id is | and not testId.

I tried to render the plugin with the vhs viewhelper request.render, but also there I have the problem passing variables.

<v:render.request action="request" controller="Form" extensionName="ExtName" pluginName="Form" vendorName="VendorName" arguments="{_all}" />

3 Answers3

4

There is another way using a global registry for variables. TYPO3 contains a so-called "LOAD REGISTER" which means a static storage for variables. The VHS extension contains ViewHelpers to interact with that storage:

https://fluidtypo3.org/viewhelpers/vhs/master/Variable/Register/GetViewHelper.html

Using the set variant you can add your variable, then call f:cObject and regardless of how deep inside the rendering stack your next fluid template sits, using the get variant retrieves the value.

Very useful if for example you use content elements with other nested content elements, e.g. retrieve or re-define the value at any nesting depth.

NB: also accessible in TypoScript as well as custom PHP executed through TYPO3, by using https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/LoadRegister/Index.html. So overall it may be much, much simpler to handle and definitely more flexible than strict passing of arguments.

Claus Due
  • 4,166
  • 11
  • 23
1

just some help (maybe) in your fluid template you can use :

<f:debug>{_all}</f:debug>

so you can check the lot of information available, otherwise in your controller:

\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($yourVariable);
webman
  • 1,117
  • 15
  • 41
0

If you define a String as data use the .current = 1 option of stdWrap:

form = COA
form {
     15 < tt_content.list.20.extname_form
     15.settings.id.current = 1
}

But your "extname_form" should use the stdWrap on the settings else you should use "variables":

form = COA
form {
     15 < tt_content.list.20.extname_form
     15.variables.id = TEXT
     15.variables.id.current = 1
}

Example for use of stdWrap for settings:

form = COA
form {
     15 < tt_content.list.20.extname_form
     15.settings.id.current = 1
}

In your controller action:

  /** @var \TYPO3\CMS\Extbase\Service\TypoScriptService $typoScriptService */
  $typoScriptService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
  $typoScriptSettings = $typoScriptService->convertTypoScriptArrayToPlainArray($this->settings);
  $this->settings['id'] = $this->configurationManager->getContentObject()->stdWrap($typoScriptSettings['id'], $typoScriptSettings['id.']);

Now your settings.id is parsed by stdWrap and should contain your cObjectViewHelper Data.

René Pflamm
  • 3,273
  • 17
  • 29
  • Thank you for your help. I tried both versions but I can't pass the variable to the fluid template of the form. – Michael Mauracher Oct 11 '16 at 10:41
  • There could be somethings in your ```extname_form``` Extension that depend on how to access variables. To examples with "variables" only work if the ```tt_content.list.20.extname_form``` is an FLUID_TEMPLATE object. Without knowing the extension you have to parse the settings in your controller and assign them to your view. – René Pflamm Oct 11 '16 at 10:47
  • I can't get it to work. Also in the form controller I can't access the variables. The form plugin is also implemented with fluidtemplate. If I use the first version I see the variable in the template. The problem there is that the variable content is not taken. – Michael Mauracher Oct 11 '16 at 11:29
  • I have edited my answer with an example for use of ```stdWrap``` within settings – René Pflamm Oct 11 '16 at 12:44
  • I'm sorry, but it does not work. I'm don't get the content of the variable. I'm calling the typoscript object like that: Is that correct? – Michael Mauracher Oct 11 '16 at 13:59
  • Than I muss pass. I have no more ideas and unfortunately not enough time to reconstruct your environment to try :( – René Pflamm Oct 11 '16 at 14:00