diff --git a/app/src/Widgets/SubmenuWidget.php b/app/src/Widgets/SubmenuWidget.php new file mode 100644 index 0000000..235286e --- /dev/null +++ b/app/src/Widgets/SubmenuWidget.php @@ -0,0 +1,39 @@ +'; + private static $table_name = 'SubmenuWidget'; + + public function getPage() + { + $area = $this->Parent(); + return \Page::get()->filter('SideBarID', $area->ID)->first(); + } + + public function getSubmenu() + { + $page = $this->getPage(); + + $children = $page->Children(); + $children = $children->count() ? $children : $page->Level(1)->Children(); + + return $children; + } +} diff --git a/app/templates/Page.ss b/app/templates/Page.ss index 31871f3..3e9fd61 100644 --- a/app/templates/Page.ss +++ b/app/templates/Page.ss @@ -20,7 +20,7 @@ $Breadcrumbs <% end_if %> - <% if $SideBarView && $SideBar.Widgets.Count %> + <% if $SideBarView && $SideBarView.Widgets.Count %>