Display Random Stack / Block?
Permalink 1 user found helpful
Wondering if there is already, or if anyone has any interest in making, something to allow you to display a random block or stack?
In other words, if you had a block created for a Testimonial, what I'd like is to be able to have a whole bunch of them entered, and then have a stack or block where you can select to display one or a set of random testimonials.
I haven't worked out in my head how exactly it would work, whether you'd display a random block or a random stack, but it would seem the most useful if you could have a set of any number of stacks created and then display any one of those at random on page-load. I suppose the biggest problem with this is that you can't nest stacks, so you can't really choose a "set" of stacks, and that would be the handy part, because you could basically have a layout of any number of blocks created.
I'm just throwing this out there. I've run across a few other uses, besides testimonials, where this would sure be handy.
On that note, are there any plans to organize stacks into folders or any other hierarchy?
In other words, if you had a block created for a Testimonial, what I'd like is to be able to have a whole bunch of them entered, and then have a stack or block where you can select to display one or a set of random testimonials.
I haven't worked out in my head how exactly it would work, whether you'd display a random block or a random stack, but it would seem the most useful if you could have a set of any number of stacks created and then display any one of those at random on page-load. I suppose the biggest problem with this is that you can't nest stacks, so you can't really choose a "set" of stacks, and that would be the handy part, because you could basically have a layout of any number of blocks created.
I'm just throwing this out there. I've run across a few other uses, besides testimonials, where this would sure be handy.
On that note, are there any plans to organize stacks into folders or any other hierarchy?
w00t for stack randomizer! :P
Works by allowing to to specify exactly what stacks to display - so it's not a "set" of stacks, but works pretty much the same way.
It's getting through the PRB - and will be free upon release.
Works by allowing to to specify exactly what stacks to display - so it's not a "set" of stacks, but works pretty much the same way.
It's getting through the PRB - and will be free upon release.
Stack Randomizer is good and free:
http://www.concrete5.org/marketplace/addons/stack-randomizer/...
I want to do something similar - but not quite that.
I have 5 photos that I would like to randomly load once per page (so not a moving slideshow, but a random image is picked per page load).
I created this in the past with a single Scrapbook (each image was an item in a scrapbook called "Family Photos") and then inserted this code into my template:
<?php
$scrapbookHelper = Loader::helper('concrete/scrapbook');
$scrapbookPage = $scrapbookHelper->getGlobalScrapbookPage();
// area name is what the scrapbook is called, scrapbooks are really just areas when you get right down to it.
$scrapbookArea = new Area("Family Photos");
$bannerBlocks = $scrapbookArea->getAreaBlocksArray($scrapbookPage);
$totalBlocks = count ($bannerBlocks) - 1;
$i = rand (0, $totalBlocks);
$bannerBlock = $bannerBlocks[$i];
$bannerBlock->display();
?>
Based on the code from:
http://www.werstnet.com/blog/display-an-area-or-a-random-scrapbook-...
Worked a treat, but I don't know how to do this now with Stacks... I've never coded this stuff myself before (always relied on generous snippets :) so I'd have to study the docs to figure it out :)
http://www.concrete5.org/marketplace/addons/stack-randomizer/...
I want to do something similar - but not quite that.
I have 5 photos that I would like to randomly load once per page (so not a moving slideshow, but a random image is picked per page load).
I created this in the past with a single Scrapbook (each image was an item in a scrapbook called "Family Photos") and then inserted this code into my template:
<?php
$scrapbookHelper = Loader::helper('concrete/scrapbook');
$scrapbookPage = $scrapbookHelper->getGlobalScrapbookPage();
// area name is what the scrapbook is called, scrapbooks are really just areas when you get right down to it.
$scrapbookArea = new Area("Family Photos");
$bannerBlocks = $scrapbookArea->getAreaBlocksArray($scrapbookPage);
$totalBlocks = count ($bannerBlocks) - 1;
$i = rand (0, $totalBlocks);
$bannerBlock = $bannerBlocks[$i];
$bannerBlock->display();
?>
Based on the code from:
http://www.werstnet.com/blog/display-an-area-or-a-random-scrapbook-...
Worked a treat, but I don't know how to do this now with Stacks... I've never coded this stuff myself before (always relied on generous snippets :) so I'd have to study the docs to figure it out :)
A good starting point would be the list files from set block (and a few image list templates I have released for it).
You would need to create a new template to pick one from the set at random, then display the full image rather than just the filename or thumbnail.
Having said that, there are probably other blocks that do things like this. Just a case of searching through the marketplace.
You would need to create a new template to pick one from the set at random, then display the full image rather than just the filename or thumbnail.
Having said that, there are probably other blocks that do things like this. Just a case of searching through the marketplace.
http://www.concrete5.org/marketplace/addons/randomizer/...
http://www.concrete5.org/marketplace/addons/random-image/...
Many listing, linking and slider addons also have random options:
http://www.concrete5.org/marketplace/addons/page-auto-redirect/...
A howto on randomizing a page area:
http://www.concrete5.org/documentation/how-tos/editors/how-to-show-...
Currently in the PRB (so the link will 404 until it is approved)
http://www.concrete5.org/marketplace/addons/stack-randomizer/...