Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flarum Custom Layout Extension
<?php
namespace Flarum\CustomLayout;
use Flarum\Support\Extension as BaseExtension;
use Illuminate\Events\Dispatcher;
use Flarum\Events\BuildClientView;
use Flarum\Forum\Actions\ClientAction as ForumClientAction;
class Extension extends BaseExtension
{
public function listen(Dispatcher $events)
{
$events->listen(BuildClientView::class, function (BuildClientView $event) {
if ($event->action instanceof ForumClientAction) {
$event->view->setLayout(__DIR__.'/forum.blade.php');
}
});
}
}
return Extension::class;
@skorotkiewicz

This comment has been minimized.

Copy link

skorotkiewicz commented Oct 4, 2015

Hot to set more Layouts?

                $event->view->setLayout(__DIR__.'/forum.blade.php');
                $event->view->setLayout(__DIR__.'/app.blade.php');
@pryley

This comment has been minimized.

Copy link

pryley commented Apr 6, 2018

use Illuminate\Events\Dispatcher;
use Flarum\Event\ConfigureClientView;

return function( Dispatcher $events ) {
    $events->listen( ConfigureClientView::class, function( ConfigureClientView $event ) {
        $template = 'forum.blade.php';
        $stringLength = strlen( $template );
        if( substr( $event->view->layout, -$stringLength ) === $template ) {
            $event->view->layout = __DIR__.'/forum.blade.php';
        }
    });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.