Displaying multiple blocks from global scrapbook with same name, and in same order.

Permalink
Hello, I have tried to use a foreach statement to get and display all blocks in the global scrapbook that have the same name. It returned an error:

Code:
$blocks = Block::getByName('Logo');
                    foreach ($blocks as $block) {
                        if ($block && $block->bID) {
                            $block->display();
                        }
                    }


Error:
FATAL ERROR: CALL TO UNDEFINED METHOD IMAGEBLOCKCONTROLLER::DISPLAY() IN /APPLICATIONS/MAMP/HTDOCS/CONCRETE5/THEMES/BACKYARDINSPIRATIONS/ELEMENTS/HEADER.PHP ON LINE 50


I am assuming the Block::getByName('Logo'); only gets the first block? If so, how do I get all of them? Thanks.

PS: Even a general pointer in the right direction would be appreciated. :-)

boomgraphics
 
12345j replied on at Permalink Reply
12345j
try
$bv = new BlockView();
$bv->render($block);

to display the block instead of $block->display()
but I don't think blocks can have the same name in the same scrapbook?
boomgraphics replied on at Permalink Reply
boomgraphics
Didn't work. :-(

I don't know if blocks can have the same name or not. I haven't had any warnings about multiple blocks though. I do know that after reordering blocks with the same name in the global scrapbook, Block::getByName() doesn't re-pick a block based on it's position in the list.

I guess I will have to learn how to use the database object to build an array of global blocks with the same name?
12345j replied on at Permalink Reply
12345j
if you have a copy of the randomizer addon it does something like this.
12345j replied on at Permalink Reply
12345j
or maybe you can add a new display function in your controller that renders the view.