Container for blocks

Permalink
I want a border for each block by defining an appropriate css property but blocks are not separated in html-containers. How can I add general properties to all blocks without hacking the c5 source code?

cgrauer
 
beeman89045 replied on at Permalink Reply
I would just create a new template for the blocks you need this CSS.

Taking an example of a Content Block, you would just create the directory structure blocks/content/templates (that mirrors the one in the core concrete directory) and then copy the Content Block's view.php into that "user" directory, then edit it to include your CSS.

content = $controller->getContent();
echo '<div id="mydiv">';
print $content;
echo '</div>';


This doesn't touch core C5 ... C5 looks for your template 1st and adds it to that Block. Then you simply select the appropriate template.

Of course, that is a fair amount of work for each Block, so you may want to explore other methods (like creating your own versions of the Core Blocks).
cgrauer replied on at Permalink Reply
cgrauer
Thanks djn12313 for your answer. I assumed that there would be such a way, but it means to change every block type. I want that every block now and in future gets a border (for example), also block types that even doesn't exist already.

In other words I was surprised that c5 does not surround every block with a div-container by default. But if this is by design I will have to go the way you told me.
beeman89045 replied on at Permalink Reply
it kind of surprises me a little too. IMO, there should be far wider use of CSS ids/classes throughout the Blocks in C5 (to allow tweaking of padding, margins, alignment as in-line styles) ... but that's just an opinion.

My suggestion was a way to do this natively using C5 and CSS by essentially overriding the view.php for each "bordered block", but there is nothing stopping you from implementing this in your design template in jQuery / Javascript, by limiting the selector scope to only areas you want bordered.

Of course, I suggest that without actually checking what each content block outputs in terms of possible selectors. So your mileage may vary.

I probably wouldn't take my chances though and just modify the templates so that you have the DIVs explicitly defined.

*BTW, if you name your new template view.php (and not myview.php) then you *should* not have to manually select the template when a new Block instance is created.*