Skip to content

Instantly share code, notes, and snippets.

@mrimann
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrimann/bcde0d7f37ded1be9de1 to your computer and use it in GitHub Desktop.
Save mrimann/bcde0d7f37ded1be9de1 to your computer and use it in GitHub Desktop.
Neos: Random Banner
prototype(Internezzo.ProjectTld:Banner) < prototype(TYPO3.Neos.NodeTypes:Image) {
node = ${q(site).find('[instanceof Internezzo.ProjectTld:Banner]').get()}
node.@process.shuffle = ${q(value).count() > 0 ? Array.shuffle(value) : value}
node.@process.slice = ${q(value).count() > 0 ? q(value).slice(0, 1).get(0) : value}
title = ${q(node).property('title')}
@cache {
mode = 'cached'
maximumLifetime = '1'
}
}
@mrimann
Copy link
Author

mrimann commented Feb 12, 2015

Line 6 seems to point to the node of the currently shown page - but not to the node fetched in lines 2-3 which would be the correct one.

@mrimann
Copy link
Author

mrimann commented Feb 12, 2015

Problem could be solved by changing get() to get(0) on line 4 which changes "node" to be an actual node object and not an array

@dimaip
Copy link

dimaip commented Feb 15, 2015

If you need just one random element, Array.random may be all you need: http://docs.typo3.org/neos/TYPO3NeosDocumentation/Appendixes/EelHelpersReference.html#array-random-array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment