Created
December 19, 2014 08:51
-
-
Save hlubek/8f0caee69a837d17f8c1 to your computer and use it in GitHub Desktop.
Reusing Fluid templates with sections in Neos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div> | |
| <h1>List of something</h1> | |
| ... | |
| <ul> | |
| <!-- This will not be rendered by default --> | |
| <f:section name="item"> | |
| <li> | |
| {itemNode.properties.title} | |
| </li> | |
| </f:section> | |
| <!-- We could as well use a Collection TS object instead of a Fluid f:for --> | |
| <f:for each="{items}" as="itemNode"> | |
| <ts:render path="itemRenderer" context="{itemNode: itemNode}" /> | |
| </f:for> | |
| </ul> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Rendering sections can also simplify node types that render collections of something to have everything in one template | |
| prototype(My.Site:List.Something) { | |
| # Auto-generated value | |
| # templatePath = 'resource://My.Site/Private/Templates/NodeTypes/List.Something.html' | |
| items = ${...some FlowQuery...} | |
| itemRenderer = TYPO3.TypoScript:Template { | |
| templatePath = 'resource://My.Site/Private/Templates/NodeTypes/List.Something.html' | |
| sectionName = 'item' | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Rendering sections is useful for using separate sections for a page template and have that in a single file | |
| page { | |
| head { | |
| stylesheets { | |
| main = TYPO3.TypoScript:Template { | |
| templatePath = 'resource://My.Site/Private/Templates/Page/Default.html' | |
| sectionName = 'stylesheets' | |
| } | |
| } | |
| } | |
| body { | |
| templatePath = 'resource://My.Site/Private/Templates/Page/Default.html' | |
| sectionName = 'body' | |
| } | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment