0
votes

I get the following error message #1237900529: The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper" while trying to iterate through the rows of my data using the following FLUIDTEMPLATE (FT) iteration:

<h2>Sources</h2>
<f:for each="{content_source}" as="source">
    <p>{source.header}</p>
</f:for>

<h2>Contact</h2>
<f:for each="{content_contact}" as="contact">
    <p>{contact.header}</p>
</f:for>

I'm running Typo3 6.2.14 and would like to parse this HTML to match with BootStrap's architecture in my custom built template. I don't have much knowledge on Typoscript & FT; it is however preferable for me to use FT over TypoScript to make conditions for html parsing. What should I adjust if I have the following TypoScript:

10 = FLUIDTEMPLATE
10{
    file= fileadmin/Templates/index.html
    layoutRootPath = fileadmin/Templates/layouts/
    partialRootPath = fileadmin/Templates/partials/
    variables {
        content_source < styles.content.get
        content_source.select.where = colPos=3
        content_contact < styles.content.get
        content_contact.select.where = colPos=4
    }
}
1
What exactly do you want to achieve? style.content.get always renders the content elements which are affected by the query (see docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/…), so the error is shown, because you try to iterate through a string instead of an array. - derhansen
@derhansen I would want to envelope the returned values with my desired html tags from within FluidTemplate. I could then also make use of conditions and comparisons functions provided my FluidTemplate for better control of html tags. Is there possibility of getting this value as an array instead of string? Or perhaps you might have better alternatives to suggest me. - Ren
I don't know if it is possible to get the content elements as an array to the fluid template. I generally see some problems the way you try to achieve your problem. Your template would become really complicated, the more you customize the content elements. I think it is best to control the HTML structures of TYPO3 content elements by TypoScript (e.g. add additional frames) - derhansen
Do I have to hard code all the HTML tags inside the Typoscript file? :( - Ren

1 Answers

2
votes

For posterity, since this question is old and likely resolved already:

When you consume a variable from TypoScript this way, you get strings of rendered content - not an array of content records or an array of rendered content HTML strings. So the error is correct.

There are two main roads one would normally take to style the HTML output of the content you render, depending on the type of content element:

  • Change the TS wrapping etc. (if you use css_styled_content) or override the templates you want to change (if you use fluid_styled_content).
  • Override the templates you want to change, for all content types and plugins which use either FLUIDTEMPLATE TS object or Extbase MVC.

Lastly, there are third party ViewHelpers you can use in Fluid to fetch raw content records and render them as well - which will allow you to apply things like wrapping to content elements as part of the Fluid template. See https://fluidtypo3.org/viewhelpers/vhs/master/Content/GetViewHelper.html and v:content.render counterpart.