From a9d4be8c0b56b833f526563e6b7e7ae43df1d327 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 27 Jul 2015 14:45:35 +0930 Subject: [PATCH] Allow customisation of the client layout --- framework/core/src/Forum/Actions/ClientAction.php | 6 +++++- framework/core/src/Support/ClientView.php | 14 ++++++++++++-- framework/core/views/app.blade.php | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/framework/core/src/Forum/Actions/ClientAction.php b/framework/core/src/Forum/Actions/ClientAction.php index 0091c4b9d..ec9404e9d 100644 --- a/framework/core/src/Forum/Actions/ClientAction.php +++ b/framework/core/src/Forum/Actions/ClientAction.php @@ -12,7 +12,7 @@ class ClientAction extends BaseClientAction /** * {@inheritdoc} */ - protected $layout = 'flarum.forum::forum'; + protected $layout = __DIR__.'/../../../views/forum.blade.php'; /** * {@inheritdoc} @@ -132,10 +132,14 @@ class ClientAction extends BaseClientAction 'core.write_a_reply' ]; + /** + * @inheritdoc + */ protected function getAssets() { $assets = parent::getAssets(); + // Add the formatter JavaScript payload. $assets->addJs(function () { return app('flarum.formatter')->getJS(); }); diff --git a/framework/core/src/Support/ClientView.php b/framework/core/src/Support/ClientView.php index c2679a6f2..b70db7f0b 100644 --- a/framework/core/src/Support/ClientView.php +++ b/framework/core/src/Support/ClientView.php @@ -41,7 +41,7 @@ class ClientView implements Renderable protected $content; /** - * The name of the client layout view to display. + * The path to the client layout view to display. * * @var string */ @@ -143,6 +143,16 @@ class ClientView implements Renderable $this->content = $content; } + /** + * Set the name of the client layout view to display. + * + * @param string $layout + */ + public function setLayout($layout) + { + $this->layout = $layout; + } + /** * Add a string to be appended to the page's . * @@ -205,7 +215,7 @@ class ClientView implements Renderable $view->title = ($this->title ? $this->title . ' - ' : '') . $forum->data->attributes->title; $view->document = $this->document; $view->forum = $forum->data; - $view->layout = $this->layout; + $view->layout = app('view')->file($this->layout, ['forum' => $forum->data]); $view->content = $this->content; $view->styles = [$this->assets->getCssFile()]; diff --git a/framework/core/views/app.blade.php b/framework/core/views/app.blade.php index df791391b..9a4cdfd92 100644 --- a/framework/core/views/app.blade.php +++ b/framework/core/views/app.blade.php @@ -16,7 +16,7 @@ - @include($layout) + {!! $layout !!}