We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    This is an auto-generated topic for <a href="http://modxcms.com/extras/package/604">RandomChunk 1.0-Stable</a> by thekiller237.

    Brief Description:
    RandomChunk randomly outputs a chunk from a list of chunks.
      • 33988
      • 110 Posts
      More support for this snippet can be found at http://salscode.com/index.php?id=50 .
        Sal Sodano
        President & Co-Founder of SkyToaster
        My Website Salscode.
        • 33988
        • 110 Posts
        Version 1.0 has just been tested for Revo and released as a transport package. Have fun.
          Sal Sodano
          President & Co-Founder of SkyToaster
          My Website Salscode.
          • 7557
          • 61 Posts
          Quote from: the_killer23 at Sep 03, 2010, 11:54 AM

          Version 1.0 has just been tested for Revo and released as a transport package. Have fun.
          Hi Killer smiley
          Little nice snippet.
          I downloaded RandomChunk from Revo package management, and I got version for Evo.
          This code:
          //Salvatore Sodano
            //http://salscode.com/index.php?id=50
            //[!RandomChunk? &chunks=`chunk1, chunk2`!]
            //Randomly generates a chunk from a comma delineated list of chunks.
            $chunks = str_ireplace(" ","",$chunks);
            $charray = explode(",",$chunks);
            $count = count($charray) - 1;
            $rand = rand(0,$count);
            $result = $charray[$rand];
            echo "{{".$result."}}";
          

          Of course not a problem, because very little difference between the Revo and Evo code. By the way I added a little extra. The time interval for chunk changes (optional).
          //Salvatore Sodano
            //http://salscode.com/index.php?id=50
            //Randomly generates a chunk from a comma delineated list of chunks.
            //Optional parameter chunk changes interval in secounds.
            //[[!RandomChunk? &chunks=`chunk1, chunk2` &change=`30`]]
            isset($change) ? srand(ceil(time()/$change)) : '' ;
            $chunks = str_ireplace(" ","",$chunks);
            $charray = explode(",",$chunks);
            $count = count($charray) - 1;
            $rand = rand(0,$count);
            $result = $charray[$rand];
            return "[[$".$result."]]";