Skip to content

Instantly share code, notes, and snippets.

@tobyzerner
Created September 11, 2015 01:54
Show Gist options
  • Save tobyzerner/19f34dcab33bafd66e4d to your computer and use it in GitHub Desktop.
Save tobyzerner/19f34dcab33bafd66e4d to your computer and use it in GitHub Desktop.
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;
@pryley
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