Stacks - SetBlockWrapperStart and other Area functions

Permalink 2 users found helpful
Currently to add a wrapper you can use the code below, this wraps each block with the html defined within the function parameters.
$a = new Area('Main');
$a->setBlockWrapperStart("<div class='cycle-image'>");
$a->setBlockWrapperEnd("</div>");


However if you want to do this to a stack, that gets a little trickier.

A stack, when used within an area appears as one block.
To grab a stack you can use,
$stack = Stack::getByName("Home Cycle Images");
$stack->display();
//Doing so, from what I can see, prevents you from accessing the area object
//instead what I have done is reverted to the older method.
        $stack = Stack::getByName("Home Cycle Images");
        $ax = Area::get($stack, STACKS_AREA_NAME);
        //provides the required area object
        $ax->setBlockWrapperStart("<div class='cycle-img'>");
        $ax->setBlockWrapperEnd("</div>");
        //(untested) I assume you could also then use $a->setCustomTemplate($block, $template);
        $ax->display($stack);


It would be nice if we could access these functions from the Stacks model.

Of course if any of this is already possible can someone point me towards the solution.

I am going to see if I can have a fiddle with the stacks model and implement it, looking through the core model it does not look too difficult to extend it to include the extra functions?

Thanks
- Sean

TheRealSean
 
JohntheFish replied on at Permalink Reply
JohntheFish
You could load the stack with a Universal Content Puller block. That way, you get the stack, but inside a regular block. So can add wrappers, block design etc.

UCP also has a wrapper plugin model, so can wrap a pulled stack in (currently) a template from a content block or from Formigo containers. This may be more flexible than using block wrappers and can all be done without code.

If you want a minimal version of loading a stack in a block, you can use the Stack Randomizer block with just 1 stack to choose from.