*/
public function handle($request, Closure $next)
{
+ // Hard coded menu structure until we have dynamic data from the CMS
$nav_items = [
'Products' => [
[
'title' => 'Capteurs',
'links' => [
- 'Force' => 'force',
- 'Couple' => 'couple',
- 'Déplacement' => 'deplacement',
- 'Accélération' => 'acceleration',
- 'Inclinaison' => 'inclinaison',
- 'Pression' => 'pression',
+ 'Force' => 'products/force',
+ 'Couple' => 'products/couple',
+ 'Déplacement' => 'products/deplacement',
+ 'Accélération' => 'products/acceleration',
+ 'Inclinaison' => 'products/inclinaison',
+ 'Pression' => 'products/pression',
],
],
[
'title' => 'Systèmes de mesure',
'links' => [
- 'Roue dynamométrique' => 'roue',
- 'Contrôle de fermeture d’ouvrants' => 'cdfdo',
- 'Contrôle de taraudage' => 'cdt',
- 'Collecteurs tournant' => 'ct',
- 'Télémétrie' => 'telemetrie',
- 'Acquisition de données' => 'add',
+ 'Roue dynamométrique' => 'products/roue',
+ 'Contrôle de fermeture d’ouvrants' => 'products/cdfdo',
+ 'Contrôle de taraudage' => 'products/cdt',
+ 'Collecteurs tournant' => 'products/ct',
+ 'Télémétrie' => 'products/telemetrie',
+ 'Acquisition de données' => 'products/add',
],
],
],
'submenus' => [
[
'links' => [
- 'Énergie' => 'energie',
- 'Aéronautique' => 'aero',
- 'Ferroviaire' => 'ferroviaire',
- 'Automobile' => 'auto',
- 'Génie civil' => 'civil',
- 'Industrie' => 'industrie',
+ 'Énergie' => 'solutions/energie',
+ 'Aéronautique' => 'solutions/aero',
+ 'Ferroviaire' => 'solutions/ferroviaire',
+ 'Automobile' => 'solutions/auto',
+ 'Génie civil' => 'solutions/civil',
+ 'Industrie' => 'solutions/industrie',
]
],
],
[
'title' => null,
'links' => [
- 'Location' => 'location',
- 'Calibration' => 'calibration',
- 'Développement OEM' => 'developpement-oem',
- 'Custom Design' => 'custom-design',
- 'Formation' => 'formation',
+ 'Location' => 'services/location',
+ 'Calibration' => 'services/calibration',
+ 'Développement OEM' => 'services/developpement-oem',
+ 'Custom Design' => 'services/custom-design',
+ 'Formation' => 'services/formation',
],
],
],
],
- 'Support' => 'support',
- 'Société' => 'company',
- 'Contact' => 'contact',
+ 'Support' => ['url' => 'support'],
+ 'Société' => [
+ 'url' => 'societe',
+ 'submenus' => [
+ [
+ 'links' => [
+ 'Qui sommes nous ?' => 'societe/a-propos',
+ 'Actualités' => 'societe/actualites',
+ ]
+ ]
+ ],
+ ],
+ 'Contact' => ['url' => 'contact'],
];
\Menu::make('primary', function ($menu) use ($nav_items) {
- // Todo: figure out how we can have the home link included in the breadcrumb menu without needing to add it to the menu like this. Also find a way to stop the home breaking when this link is not in the menu...
- $menu->add('Home', '');
-
foreach ($nav_items as $nav_label => $nav_item) {
+ $parent = $menu->add($nav_label, $nav_item['url']);
+
// Handle items with submenus
- if (is_array($nav_item)) {
- $parent = $menu->add($nav_label, $nav_item['url']);
+ if (isset($nav_item['submenus'])) {
foreach ($nav_item['submenus'] as $submenu_data) {
+ // Create an empty sub-element that will serve as a wrapper for the submenu(s)
+ $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']);
+
+ // Some submenus have a title element
+ if (isset($submenu_data['title'])) {
+ $wrapper->raw($submenu_data['title'])->attr(['class' => 'nav-submenu-title']);
+ }
+
foreach ($submenu_data['links'] as $label => $url) {
- $parent->add($label, $url);
+ $wrapper->add($label, $url);
}
+ }
+ }
- /*
- $parent->add($submenu_data['title'] ?? 'SUBMENU');
+ }
- $parent->group(['prefix' => $nav_item['url']], function ($submenu) use ($submenu_data) {
+ });
- foreach ($submenu_data['links'] as $label => $url) {
- $submenu->add($label, $url);
- }
+ // Also make a menu for the breadcrumbs - this one is simpler and doesn't have the submenu headings
+ \Menu::make('breadcrumbs', function ($menu) use ($nav_items) {
- });
- */
- }
+ // Start with home link
+ $menu = $menu->add('Home', '');
- // Simple nav items with no sub-menus
- } else {
- $menu->add($nav_label, $nav_item);
- }
- }
+ foreach ($nav_items as $nav_label => $nav_item) {
+
+ $parent = $menu->add($nav_label, $nav_item['url']);
+ // Handle items with submenus
+ if (isset($nav_item['submenus'])) {
+ foreach ($nav_item['submenus'] as $submenu_data) {
+ foreach ($submenu_data['links'] as $label => $url) {
+ $parent->add($label, $url);
+ }
+ }
+ }
+ }
});
return $next($request);