We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6955 ☆ A M B ☆
    • 147 Posts
    Do we have a plugin or a potential tool that can do like an image rotator for the header? I am looking for an image rotator that I can utilize and it works in Modx for the header. I am currently using the Evolution 1.0 RC for this - I wanted to go Revolution but apparently most the plugins and stuff are all functional in Evolution than Revolution. smiley Thats okay! laugh But any suggestions?

    Thanks for making such a great product!
      Billy Koch
      Follow me on Twitter: @DefKoch
      Skype: billyk0ch
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Do you want it to be a random image taken from a given folder of images? If so, I use this
      <?php
      // get images from bg image directory
      if ($handle = opendir('./assets/images/top')) {
          $i = 1;
          while (false !== ($file = readdir($handle))) {
              if (substr($file, 0, 1) != ".") {
               $images[$i] = $file;
               $i++;  
              }       
          }
          closedir($handle);
      } 
      
      //return a random filename
      $randomimage = rand(1, count($images));
      return $images[$randomimage];
      ?>

      And use it like this in my template as a background image:
      <style type="text/css">
      #topblock {
          background: #7d96bc url(assets/images/top/[!RandomImage!]) center no-repeat;
      }
      </style>
      }
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 6955 ☆ A M B ☆
        • 147 Posts
        This JUST might work! Will give it a whirl!

        Thanks a million!

        Okay you guys are showing how it is also important to totally understand and utilize php! smiley
          Billy Koch
          Follow me on Twitter: @DefKoch
          Skype: billyk0ch
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Or ask, and somebody else will probably have something that does much the same thing for one of their sites that they’ll share wink

          Here’s another random image snippet http://modxcms.com/extras/package/?package=364

          You also might find this interesting http://modxcms.com/forums/index.php?topic=28480.0
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 3749
            • 24,544 Posts
            Quote from: sottwell at Jul 05, 2009, 11:08 PM

            //return a random filename
            $randomimage = rand(1, count($images));
            return $images[$randomimage];
            ?>

            I think this might be significantly faster (though proabably not noticably so):

            return (array_rand($images));   
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Never heard of that one... looks like it’s time to go back to reading docs instead of trashy romance novels!
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 3749
                • 24,544 Posts
                Quote from: sottwell at Jul 06, 2009, 03:24 AM

                Never heard of that one... looks like it’s time to go back to reading docs instead of trashy romance novels!
                Actually, I found that in a trashy romance novel. wink
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting