[support] Randomly display one block from a list of blocks
William Smith
william.darren at gmail.com
Mon Apr 6 11:24:39 UTC 2009
It sounds more like a code snippet than a module proper. Shouldn't be
more than about 4 lines of code. Create a block, set it to PHP mode,
and make the contents something like the following (this is untested
code, mind you):
$blocks = array('my block 1', 'my block 2', 'my block 3');
$key = rand(0, count($blocks)-1);
$block = module_invoke($blocks[$key], 'block', 'view', 0);
print $block;
On Sun, Apr 5, 2009 at 6:15 PM, George <g at 8vue.com> wrote:
> hi, ok, so i'd like to display one block from a set list of blocks randomly
> in one particular region - like, latest news, latest articles, advert etc
> (each with different designs). for anon views, i wouldn't really mind if it
> only updates when the cache expires.
>
> after looking through the module list, i didn't seem to find anything
> suitable, so i've considered writing my own module - like a block switcher
> module where modules for one region are randomly switched, but before i do,
> is there already something that could actually do this out there, just not
> well known?
>
> thanks
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
More information about the support
mailing list