1

I need to wrap a custom number of blocks on a page to apply a grid system to them.

I know about setBlockWrapperStart() and setBlockWrapperEnd(), but these are applied after each block that is generated.

Let's say I have 12 Blocks of a given type and I want to wrap the first one at the beginning with <div class="row"> and after the 4th one I want to append </div>. And with next (5th block) I want to start with <div class="row"> again...

Is there any way to implement that with concrete 5? I use the standard output right now and couldn't figure out how to add a loop or something to it to implement my approach:

$b = new Area('Test Block');
$b->display($c);

I'm using concrete 5.6.3.4. Thank you!

Sebsemillia
  • 9,366
  • 2
  • 55
  • 70

2 Answers2

0

I think you might have to use a quick and dirty hack and add HTML blocks with your markup in them in between your other blocks

Nour Akalay
  • 429
  • 3
  • 4
0

I ended up doing an override.

For this I copied the area.php from concrete/models/ to models/area.phpand inserted the function display(&$c, $alternateBlockArray) {...} from concrete/core/models/area.php and adjusted it to my needs. With this I'm save for future CMS updates and can adjust the function without accidentally "destroying" the core functionality. :)

If you have any questions regarding this, feel free to ask me!

Sebsemillia
  • 9,366
  • 2
  • 55
  • 70
  • That's a good idea but how do you deal with different situations? Say when you don't want the wrapper? Did you set a variable or something? – Nour Akalay Jun 02 '16 at 09:28
  • Yes, I check if the blocktype handle is the one I need. It's easy to filter according to your needs, all the info you need are in the $c and $b objects.. – Sebsemillia Jun 02 '16 at 09:44