Board Templates

Board Templates

When you create a board, you'll assign that board to a template. All available board templates are installed via content XML, similarly to summary templates. Here is the XML that installs the board template available in the Atomik theme:

<boardtemplates>
    <template handle="blog" name="Blog"
              icon="blank.png" package="">
    </template>
</boardtemplates>

This means that the "Blog" template will be available when creating a board, provided you've installed the Atomik sample content.

Board Driver

Unlike summary templates, board templates must provide a driver class, and register the driver. The Atomik theme registers the blog board template driver by implementing the createBlogDriver method in the Concrete\Core\Board\Template\Driver\Manager class, but third party developers may extend this class by implementing something like the following:

use Concrete\Core\Board\Template\Driver\Manager as BoardTemplateManager;
use Foo\Bar\Board\Template\Driver\FooBarDriver;

...

$boardTemplateManager = $this->app->make(BoardTemplateManager::class);
$boardTemplateManager->extend('foo_bar', function() {
    return $this->app->make(FooBarDriver::class);
});

This will ensure that any board template with the handle foo_bar will use the FooBarDriver class as its driver.

What do these driver classes do? They inform the system how many slots the template contains, and provide any custom display logic for how to populate those slots with content. We will look at them in a second.

Board Template File

Let's look at the blog template, which can be found at concrete/themes/atomik/elements/boards/blog.php:

<?php defined('C5_EXECUTE') or die("Access Denied.");?>
<div class="container ccm-board-blog">
    <div class="row pb-4 mb-4">
        <div class="col-md-12 blog-featured-post">
            <?php
            $slot->display(1);
            ?>
            <hr class="d-md-none d-block mb-0">
        </div>
    </div>
    <div class="row gx-8">
        <div class="col-md-8">
            <?php
            if ($slot->hasContents(2)) {
            ?>
            <div class="row">
                <div class="col-md-12">
                    <?php
                    $slot->display(2);
                    ?>
                </div>
            </div>
            <?php } ?>
            <?php
            if ($slot->hasContents(3)) {
            ?>
            <div class="row">
                <div class="col-md-12">
                    <hr class="d-none d-md-block">
                    <?php
                    $slot->display(3);
                    ?>
                </div>
            </div>
            <?php } ?>
            <?php
            if ($slot->hasContents(4)) {
            ?>
            <div class="row">
                <div class="col-md-12">
                    <hr class="d-none d-md-block">
                    <?php
                    $slot->display(4);
                    ?>
                </div>
            </div>
            <?php } ?>
            <?php
            if ($slot->hasContents(5)) {
            ?>
            <div class="row">
                <div class="col-md-12">
                    <hr class="d-none d-md-block">
                    <?php
                    $slot->display(5);
                    ?>
                </div>
            </div>
            <?php } ?>
        </div>
        <div class="col-md-4 col-blog-sidebar mt-3 mt-md-0">
            <?php
            $stack = Stack::getByName('Blog Sidebar');
            if ($stack) {
                $stack->display();
            }
            ?>
        </div>
    </div>
</div>

The board template is just HTML and PHP, like other template files in Concrete CMS. It uses Bootstrap 5 markup for styling and display. The only real board-specific PHP here are the various operations that take place on the $slot object, which is automatically available to the template file.

The board driver and the board template file work together to populate your boards with content.