FIX: fix onepage menu
This commit is contained in:
@@ -23,7 +23,7 @@ class SetHomepage extends Controller
|
||||
/**
|
||||
* SetHomepage constructor.
|
||||
*
|
||||
* @param Content $content
|
||||
* @param IContent $content
|
||||
*/
|
||||
public function __construct(IContent $content)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Templates\Base\OnePage\Widgets\OnePageMenu;
|
||||
|
||||
use App\CMS\Contracts\Repositories\Content as IContent;
|
||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||
use App\CMS\Helpers\Settings;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Widgets\Widget;
|
||||
use App\Models\Widgets\WidgetType;
|
||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||
use Templates\Base\OnePage\Handlers\OnePage;
|
||||
|
||||
class Presenter implements WidgetRenderer
|
||||
@@ -15,7 +19,6 @@ class Presenter implements WidgetRenderer
|
||||
|
||||
/**
|
||||
* Method used for displaying widget.
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param Widget $widget
|
||||
@@ -27,10 +30,24 @@ class Presenter implements WidgetRenderer
|
||||
{
|
||||
if (!self::$template) {
|
||||
self::$template = "menu";
|
||||
// throw new \ErrorException('Cannot render menu without template! Please, set Presenter::$template variable before rendering.');
|
||||
// throw new \ErrorException('Cannot render menu without template! Please, set Presenter::$template variable before rendering.');
|
||||
}
|
||||
|
||||
$pages = OnePage::getPagesOnHomepage();
|
||||
$usedPagesIds = (array)Settings::getJson(OnePage::HOMEPAGE_PAGES_SETTINGS_KEY);
|
||||
$contentPages = Content::whereIn('id', $usedPagesIds)
|
||||
->get()
|
||||
->keyBy('id');
|
||||
|
||||
// need to maintain order of pages
|
||||
$homepage = app(IContent::class)->getHomepage();
|
||||
$pages = collect();
|
||||
|
||||
$pages->push($homepage);
|
||||
foreach ($usedPagesIds as $pageId) {
|
||||
if (isset($contentPages[$pageId])) {
|
||||
$pages->push($contentPages[$pageId]);
|
||||
}
|
||||
}
|
||||
|
||||
return view(self::$template, ['pages' => $pages, 'widget' => $widget])->render();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user