Board Slot Templates

Nov 1, 2021
By andrew

Board Slot Templates

Every board template marks its slots by number with code like $slot->display(1). Within these slots are placed content objects that each use a particular Slot Template.

All available board slot templates are installed via content XML, similarly to summary templates. Here is the XML that installs the board slot template available in the Atomik theme:

<boardslottemplates>
    <template handle="blog_image_left" name="Blog Image Left"
              icon="blank.png" package="">
    </template>
    <template handle="blog_image_right" name="Blog Image Right"
              icon="blank.png" package="">
    </template>
    <template handle="blog_two_up" name="Blog Two Up"
              icon="blank.png" package="">
    </template>
    <template handle="blog_three_up" name="Blog Three Up"
              icon="blank.png" package="">
    </template>
</boardslottemplates>

Board Slot Template Driver

Like board templates, board slot templates must provide a driver class, and register the driver. The Atomik theme registers the "Blog Image Left" slot template driver by implementing the createBlogImageLeftDriver method in the Concrete\Core\Board\Template\Slot\Driver\Manager class, but third party developers may extend this class by implementing something like the following:

use Concrete\Core\Board\Template\Slot\Driver\Manager as BoardSlotTemplateManager;
use Foo\Bar\Board\Template\Slot\Driver\FooBarSlotDriver;

...

$boardSlotTemplateManager = $this->app->make(BoardSlotTemplateManager::class);
$boardSlotTemplateManager->extend('foo_bar_slot', function() {
    return $this->app->make(FooBarSlotDriver::class);
});

This will ensure that any time a board uses the "Foo Bar Slot" slot template, it will use the FooBarSlotDriver class as its driver.

What do these board slot template driver classes do? They inform the system how many slots the content slots the board contains, and implement any slot filtration logic for content placement. More information on how these slots and board template drivers interact in the next section

Board Slot Template File

Let's look at a couple core examples of a board slot template file:

Blog Image Left

Found at concrete/themes/atomik/elements/boards/slots/blog_image_left.php

$slot->display(1);

No, there's not much there. That's because many times board slot templates exist simply to give a place to output a single item of content. If that's the case, there likely won't be any HTML or PHP wrapping around that content.

Blog Two Up

<div class="row">
    <div class="col-md-6">
        <?php $slot->display(1); ?>
    </div>
    <div class="col-md-6">
        <?php $slot->display(2); ?>
    </div>
</div>

Now we're getting somewhere. This board slot template actually contains two content slots, which are output as columns.

Blog Three Up

<div class="row">
    <div class="col-md-4">
        <?php $slot->display(1); ?>
    </div>
    <div class="col-md-4">
        <?php $slot->display(2); ?>
    </div>
    <div class="col-md-4">
        <?php $slot->display(3); ?>
    </div>
</div>

And this template does the same, but with three content slots.

Hopefully some things are becoming clearer here; when boards place content into slots, they aren't necessarily just dumping it all in a single column, one right after the other. Instead, they're choosing a board template, which itself populates content in various slots, and within each one of those slots specific granular pieces of content can be placed. That means sometimes when you create the Atomik blog board you'll get a layout with one piece of content right after the other, but sometimes you'll get three blog entry posts next to each other in a nice three column layout. Boards are meant to be dynamic and flexible – but are guaranteed to always look great.

Was this information useful?
Thank you for your feedback.