Last active
December 10, 2015 21:08
-
-
Save jaygilmore/4492603 to your computer and use it in GitHub Desktop.
A MODX Revolution Version of Sal Sodano's RandomChunk to randomly display Chunks. Ideally used with Jason Coward's getCache.
This file contains 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
<?php | |
/* | |
* RandomChunk | |
* Salvatore Sodano | |
* http://salscode.com | |
* Revolution Version 2013, Jay Gilmore aka smashingred | |
* [[!RandomChunk? &chunks=`chunk1, chunk2`]] | |
* Randomly generates a chunk from a comma separated list of chunks. | |
* | |
*/ | |
$chunks = str_ireplace(" ","",$chunks); | |
$charray = explode(",",$chunks); | |
$count = count($charray) - 1; | |
$rand = rand(0,$count); | |
$chunk = $charray[$rand]; | |
$output = $modx->getChunk($chunk); | |
return $output; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment