\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Cubist\Backpack\app\Middleware\EmailObfuscate::class,
- \App\Http\Middleware\Menu::class,
],
'api' => [
+++ /dev/null
-<?php
-
-
-namespace App\Http\Middleware;
-
-
-use Cubist\Backpack\app\Magic\Menu\Facade as CubistMenu;
-use Illuminate\Http\Request;
-use \Closure;
-
-class Menu
-{
- public function handle(Request $request, Closure $next)
- {
- CubistMenu::registerMenuMaker('pmi', [$this, 'makePMIMenu']);
- return $next($request);
- }
-
- public function makePMIMenu($menu, $item)
- {
- foreach ($item->getChildren() as $child) {
- if (!$child->isMenuDesktop()) {
- continue;
- }
- $parent = $menu->add($child->getTitle(), $child->getHref());
-
- // Handle items with submenus
- if ($child->hasChildren()) {
- // Create an empty sub-element that will serve as a wrapper for the submenu(s)
-
- if ($child->getType() == 'mega') {
- foreach ($child->getChildren() as $submenu) {
- $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']);
- $wrapper->raw($submenu->getTitle())->attr(['class' => 'nav-submenu-title']);
- foreach ($submenu->getChildren() as $subitem) {
- $wrapper->add($subitem->getTitle(), $subitem->getHref());
- }
- }
- } else {
- $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']);
- foreach ($child->getChildren() as $subitem) {
- $wrapper->add($subitem->getTitle(), $subitem->getHref());
- }
- }
- }
- }
- }
-}
+++ /dev/null
-<?php
-
-namespace App;
-
-trait PageTemplates
-{
- /*
- |--------------------------------------------------------------------------
- | Page Templates for Backpack\PageManager
- |--------------------------------------------------------------------------
- |
- | Each page template has its own method, that define what fields should show up using the Backpack\CRUD API.
- | Use snake_case for naming and PageManager will make sure it looks pretty in the create/update form
- | template dropdown.
- |
- | Any fields defined here will show up after the standard page fields:
- | - select template
- | - page name (only seen by admins)
- | - page title
- | - page slug
- */
-
-
-}
{
parent::init();
+ $this->addField([
+ 'name' => 'intro',
+ 'type' => 'BunchOfFields',
+ 'bunch' => 'App\SubForms\Intro',
+ 'label' => 'Introduction',
+ 'tab' => 'Introduction',
+ 'translatable' => true,
+ ]);
+
$this->addField(['name' => 'category',
'type' => 'SelectFromModel',
'optionsmodel' => ProductType::class,
'allows_multiple' => true,
'order' => true]);
}
-
- public function setMenuChildren($menu)
- {
- $menu->setType('mega');
-
- $productTypes = ProductType::whereVariant($menu->getVariant())->get();
- $products = Product::whereVariant($menu->getVariant())->get();
-
- $categories = $menu->getPageData()->get('categories');
- if (null === $categories || !$categories) {
- return;
- }
- foreach ($productTypes as $productType) {
- if (!in_array($productType->id, $categories)) {
- continue;
- }
- $category = new PageItem();
- $category->setVariant($menu->getVariant());
- $category->setLocale($menu->getLocale());
- $category->initFromEntity($productType);
- $category->setTitle($productType->name);
- $category->setHref($productType->getSlugOrTitleAttribute());
- $category->setId('product_type/' . $productType->id);
- $category->setController(['controller' => 'ProductController', 'action' => 'productList', 'params' => ['id' => $productType->id]]);
- $category->showInAllMenus();
-
- $count = 0;
- foreach ($products as $product) {
- if ($product->product_type != $productType->id) {
- continue;
- }
- if (!$product->online) {
- continue;
- }
- $detail = new PageItem();
- $detail->setLocale($menu->getLocale());
- $detail->setVariant($menu->getVariant());
- $detail->initFromEntity($product);
- $detail->setTitle($product->name);
- $detail->setHref($product->getSlugOrTitleAttribute());
- $detail->setId('product/' . $product->id);
- $detail->setController(['controller' => 'ProductController', 'action' => 'productDetails', 'params' => ['id' => $product->id]]);
- $detail->hideInAllMenus();
- $category->addChild($detail);
- $count++;
- }
-
- if ($count) {
- $menu->addChild($category);
- }
- }
- }
-
}
$news = NewsModel::whereVariant()->get();
+ $i = 0;
+
foreach ($news as $newsItem) {
// Don't include offline items
continue;
}
- // Todo: see if we should handle events differently? Should events have a different ID + URL and maybe a different controller action in case we need a different layout?
+ // exclude events
+ if ($newsItem->getPageData()->get('type') == 'event') {
+ continue;
+ }
+
$item = new PageItem();
$item->initFromEntity($newsItem);
$item->setLocale($menu->getLocale());
$item->setVariant($menu->getVariant());
$item->setTitle($newsItem->title);
- $item->setHref($newsItem->slug); // Todo: consider having a configurable / translatable prefix for news URLs
+ $item->setHref($newsItem->slug);
$item->setId('news/' . $newsItem->id);
$item->setController(['controller' => 'NewsController', 'action' => 'view', 'params' => ['id' => $newsItem->id]]);
- $item->hideInAllMenus();
+
+ // Only show 10 latest news in the menus
+ if ($i <= 9) {
+ $item->showInAllMenus();
+ } else {
+ $item->hideInAllMenus();
+ }
$menu->addChild($item);
+
+ $i++;
}
Debugbar::stopMeasure('nav_news');
$item->setHref($application->getSlugOrTitleAttribute());
$item->setId('application/' . $application->id);
$item->setController(['controller' => 'ApplicationController', 'action' => 'view', 'params' => ['id' => $application->id]]);
- $item->hideInAllMenus();
+ $item->showInAllMenus();
$menu->addChild($item);
}
&:hover
> ul // First level submenus
- display: flex // Set to flex so we can have 2 menus side-by-side in submenu
+ display: block // Set to flex so we can have 2 menus side-by-side in submenu
animation: submenu-fade-in 0.3s
// Top level links
margin-top: 1rem // Extra margin to replace top: 100% (see IE11 notes above)
padding: 1em 0
-// Submenu items
-.nav-submenu-wrapper ul
- @apply bg-white // For IE 11
-
- li
- &:hover, &.active
- a
- @apply text-primary
- transform: translateX(0)
-
- &:before
- transform: scaleX(1)
-
- // Submenu links
- a
- @apply text-navy flex items-center w-full py-2
- white-space: nowrap
- padding-right: 1.5em // Give space to translate into
- padding-left: @padding-right
- transform: translateX(-2em)
-
- // Animated dash before link
- &:before
- content: ''
- display: block
- width: 1.5em
- height: 2px
- margin-right: 0.5em
- background: currentColor
- transform: scaleX(0)
- transform-origin: right
-
- // Set transition for links - same for both elements
- a, a:before
- transition: transform 0.2s ease-out
-
-.nav-submenu-title
- @apply bg-grey-100 text-lg text-navy px-6 py-5 -mt-4 mb-2
- min-width: 285px // Make sure both columns are a bit closer in width
-
+ li
+ &:hover, &.active
+ a
+ @apply text-primary
+ transform: translateX(0)
+
+ &:before
+ transform: scaleX(1)
+
+ // Submenu links
+ a
+ @apply text-navy flex items-center w-full py-2
+ white-space: nowrap
+ padding-right: 1.5em // Give space to translate into
+ padding-left: @padding-right
+ transform: translateX(-2em)
+
+ // Animated dash before link
+ &:before
+ content: ''
+ display: block
+ width: 1.5em
+ height: 2px
+ margin-right: 0.5em
+ background: currentColor
+ transform: scaleX(0)
+ transform-origin: right
+
+ // Set transition for links - same for both elements
+ a, a:before
+ transition: transform 0.2s ease-out
#mobile-nav
+below($breakpoint-menu)
-{!! CubistMenu::get('#main','pmi')->asUl(['class' => 'nav-primary']) !!}
+{!! CubistMenu::get('#main')->asUl(['class' => 'nav-primary']) !!}