NOTE: This repository is not maintained anymore and archived. Use https://github.com/PhileCMS/phileTwigFilters instead.
Shuffle an associative array with Twig
php composer.phar require phile/twig-shuffle:*
- Install Phile
- Clone this repo into
plugins/phile/twigShuffle
After you have installed the plugin. You need to add the following line to your config.php
file:
$config['plugins']['phile\\twigShuffle'] = array('active' => true);`
There will now be a new twig function called shuffle
. It takes an array and shuffles it up.
Example:
<ul>
{% for page in shuffle(pages) %}
<li>{{ page.title }}</li>
{% endfor %}
</ul>
The output will be a randomized array for the pages
object.