Skip to main content

Template Loader

On this page, you can learn about additional functions provided in the template loader.

Template Actions

In the loader, you can perform certain actions when installing, disabling, enabling, or uninstalling a template:

ThemeLoader.php
public function install()
{
// I will be called only on installation
}

public function disable()
{
// I will be called only when disabled
}

public function activate()
{
// When activated, I'll be here
}

public function uninstall()
{
// Oh no, I've been uninstalled, something must be done...
}

Module Overriding

The loader has the ability to override module templates. This allows editing module interfaces without directly modifying their interfaces:

ThemeLoader.php
public function register()
{
$this->addCustomPath(mm("Monitoring", "Resources/views/index"), 'modules/monitoring/index');
}

The first argument is the path to the module interface, and the second is the path within the template.

Components

The loader provides the ability to extend BladeOne by adding components.

Components are directives that can be used as shown below:

ThemeLoader.php
public function register()
{
$this->addComponentLayout('navigation', 'components/navigation');
}

And in the template itself (will call components/navigation):

layout.blade.php
@navigation

Loading Translations

In the loader, you can add translations for the template using the loadTranslations() function:

ThemeLoader.php
public function register()
{
$this->loadTranslations();
}
info

All translations must be inside the template in the i18n/ folder.