David Apltauer
David Apltauer

Reputation: 983

How to render page content using Fluid

Is it possible to render content of a page (presumably multiple let us say image+text articles) using Fluid? I would like to have more control over the html (Is it a valid reason?). I tried to fetch something I thought could be an array of some objects (rows) via TypoScript, but when assigned to a variable and used in fluid:for it results in a string and therefore a type error, so this does not work:

arr = COA
arr.10 = CONTENT
arr.10 {   
  table = tt_content
  select {  
    languageField=sys_language_uid
    where = colNum = 1
  }
}

<f:for each="{arr}" as="article" iteration="itemIteration">
abcd
</f:for>

Upvotes: 3

Views: 10112

Answers (2)

Clara Webber
Clara Webber

Reputation: 1

You need to set render="false" ! Then it works even with html format

<v:content.render column="0" pageUid="5" render="false" as="listItem">
                <f:for each="{listItem}" as="contentElement">
                    <f:format.html>{contentElement.bodytext}</f:format.html>
                </f:for>
</v:content.render>

Upvotes: 0

lorenz
lorenz

Reputation: 4558

You can't do that out of the box. But the extension "vhs" enables you to do so, have a look at the RenderViewHelper.

This would get you the first 10 contents on colPos 0 of page 5 and stores them in the variable contentElements. You then iterate through the content objects:

<v:content.render column="0" limit="10" pageUid="5" as="contentElements">
  <f:for each="{contentElements}" as="contentElement">
    <f:format.html>{contentElement.bodytext}</f:format.html>
  </f:for>
</v:content.render>

Upvotes: 7

Related Questions