Allow customisation of the client layout

This commit is contained in:
Toby Zerner 2015-07-27 14:45:35 +09:30
parent 01b225fd6d
commit a9d4be8c0b
3 changed files with 18 additions and 4 deletions

View File

@ -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();
});

View File

@ -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 <head>.
*
@ -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()];

View File

@ -16,7 +16,7 @@
</head>
<body>
@include($layout)
{!! $layout !!}
<div id="modal"></div>
<div id="alerts"></div>