Last active
August 29, 2015 14:15
-
-
Save mrimann/bcde0d7f37ded1be9de1 to your computer and use it in GitHub Desktop.
Neos: Random Banner
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
prototype(Internezzo.ProjectTld:Banner) < prototype(TYPO3.Neos.NodeTypes:Image) { | |
node = ${q(site).find('[instanceof Internezzo.ProjectTld:Banner]').get()} | |
[email protected] = ${q(value).count() > 0 ? Array.shuffle(value) : value} | |
[email protected] = ${q(value).count() > 0 ? q(value).slice(0, 1).get(0) : value} | |
title = ${q(node).property('title')} | |
@cache { | |
mode = 'cached' | |
maximumLifetime = '1' | |
} | |
} |
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
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
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.