TYPO3: Pass multiple arguments to a partial from a fluid template
Asked Answered
R

2

10

I have a fluid template, from where I call an often used snippet (called "partial"):

Template:

<f:render partial="fbLikeBox" arguments="{settings}"/>

Partial fbLikeBox.html:

<div id="fb-root"></div><script src="http://connect.facebook.net/xxxxxxxx"></script>
<fb:like href="{settings.baseURL}/details/?guide_uid={audioguide.uid}">
</fb:like>

As you can see, I need both values from the {settings} and the {audioguide} array passed to the partial. How can I achieve that?

Renaterenato answered 5/10, 2011 at 22:43 Comment(0)
A
36

Starting with TYPO3 4.6, you could just use

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

The {_all} will simple make sure all variables currently available in your template, are available in the partial.

Arabia answered 12/6, 2012 at 21:22 Comment(3)
Cool solution, however occasionally I get the exception: The argument "arguments" was registered with type "array", but is of type "object" in view helper. This might happen when I call nested partials. Using below method works fine.Renaterenato
Also, with {_all} you might run into performance issues. If loading time is too long, try to reduce the number of arguments.Renaterenato
This is not an answer to to OP's question. While it might work for the OP, the answer from konsolenfreddy is correctPeru
O
31

you can use an array, like:

<f:render partial="fbLikeBox" arguments="{settings : settings, audioguide:audioguide}"/>

They're key : value pairs where the value defines the accessible name in your partial

Oresund answered 6/10, 2011 at 7:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.