Wrapping blocks
Permalink
One of the few annoyances I've found with C5 is the inability (AFAIK) to optionally wrap an arbitrary group of blocks in some code, e.g. .
My use case is I have various page templates, some of which define a sidebar. Not everything in that sidebar should automatically be wrapped in the aside tag (so I can't put it in the template or use a block wrapper per Area), nor should it be only certain blocks that can be wrapped like this (which prevents custom block templates), and I didn't really want to make a custom template for every block type anyway.
From a trawl of the forums and my own impressions, I've determined the only flexible way to do this is a slightly hacky open/close block - you add one of it at the start, and one at the end. This works and is infinitely flexible, but not the easiest to use.
Out of curiosity is there a better way?
<aside>
My use case is I have various page templates, some of which define a sidebar. Not everything in that sidebar should automatically be wrapped in the aside tag (so I can't put it in the template or use a block wrapper per Area), nor should it be only certain blocks that can be wrapped like this (which prevents custom block templates), and I didn't really want to make a custom template for every block type anyway.
From a trawl of the forums and my own impressions, I've determined the only flexible way to do this is a slightly hacky open/close block - you add one of it at the start, and one at the end. This works and is infinitely flexible, but not the easiest to use.
Out of curiosity is there a better way?
I don't know if this is possible in 5.7, but can't you add your blocks into a stack and assign a CSS class through the "Design" element when adding the stack to the site? Seems to work in 5.6.3 ...
Ok, I just tried it myself and it works. Add your blocks to a stack, place the stack on the page and define a class via the design-dialog.
Only new thing to v.5.7: You need to pre-define the class in page_themes.php ... I believe...
Only new thing to v.5.7: You need to pre-define the class in page_themes.php ... I believe...
Damn, that does sound a little better, will give it a try.
Have to admit I haven't used Stacks at all yet, the impression I got from the docs was that they were for quickly inserting commonly used groups of blocks, which didn't sound like something I wanted.
Have to admit I haven't used Stacks at all yet, the impression I got from the docs was that they were for quickly inserting commonly used groups of blocks, which didn't sound like something I wanted.
Yeah, thats one goal to use them for, but they can be used for different things as well :)