Skip to content
W
Sign in

Boxes

A box is a method in the application tree that returns rendered output. Database rows attach it to a site and section.

Static and data-backed boxes

A static box renders a view. A data-backed box reads through a model and passes data to that view. Both extend Wbengine\Box\WbengineBoxAbstract and belong under App\Box\<Section>.

<?php
namespace App\Box\Central;

use Wbengine\Box\WbengineBoxAbstract;

class Welcome extends WbengineBoxAbstract
{
    public function Welcome(): string
    {
        return $this->getRenderer()->render(
            $this->getBoxTemplatePath(),
            ['name' => 'World']
        );
    }
}

Create src/View/Central/Welcome.tpl and bind module welcome, method welcome to a section and site in cms_boxes. Pass SQL values as bound parameters. Keep database access in a model when the box needs reusable query logic.