FEATURE: prepare widget for displaying menu on onepage templates
This commit is contained in:
@@ -32,30 +32,42 @@ abstract class OnePage implements TemplateHandler
|
||||
$menu->route('template.setHomepage', trans('template::admin/mainMenu.setHomepage'), [], 1, ['icon' => 'fa fa-fw fa-home']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for pages displayed on homepage
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPagesOnHomepage()
|
||||
{
|
||||
$pageIds = (array)json_decode(Settings::get(self::HOMEPAGE_PAGES_SETTINGS_KEY, '[]'));
|
||||
|
||||
if (empty($pageIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// get all available pages
|
||||
$pages = Content::whereIn('id', $pageIds);
|
||||
|
||||
if (Auth::user()) {
|
||||
$pages = $pages->where('status', '!=', Content::STATUS_DRAFT);
|
||||
} else {
|
||||
$pages = $pages->where('status', Content::STATUS_PUBLIC);
|
||||
}
|
||||
|
||||
return $pages->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Content object to be rendered using Blade template
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function beforeRender(Content & $content)
|
||||
{
|
||||
if ($content->is_homepage) {
|
||||
$pageIds = (array)json_decode(Settings::get(self::HOMEPAGE_PAGES_SETTINGS_KEY, '[]'));
|
||||
|
||||
if (empty($pageIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// get all available pages
|
||||
$pages = Content::whereIn('id', $pageIds);
|
||||
|
||||
if (Auth::user()) {
|
||||
$pages = $pages->where('status', '!=', Content::STATUS_DRAFT);
|
||||
} else {
|
||||
$pages = $pages->where('status', Content::STATUS_PUBLIC);
|
||||
}
|
||||
|
||||
$pages = $pages->get();
|
||||
$pages = self::getPagesOnHomepage();
|
||||
|
||||
// create real content from pages
|
||||
$pagesRaw = $pagesInTemplates = [];
|
||||
|
||||
Reference in New Issue
Block a user