Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Created January 29, 2014 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaycs85/8690309 to your computer and use it in GitHub Desktop.
Save vijaycs85/8690309 to your computer and use it in GitHub Desktop.
<?php
function menu_get_Links_source($name, $default) {
$config = \Drupal::config('menu.settings');
// When menu module is not enabled, we need a hardcoded default value.
return module_exists('menu') ? $config->get('main_links') : 'main';
}
/**
* Returns an array of links to be rendered as the Main menu.
*/
function menu_main_menu() {
$main_links_source = menu_get_Links_source('main_links', 'main');
return menu_navigation_links($main_links_source);
}
/**
* Returns an array of links to be rendered as the Secondary links.
*/
function menu_secondary_menu() {
$main_links_source = menu_get_Links_source('main_links', 'main');
$secondary_links_source = menu_get_Links_source('secondary_links', 'account');
// If the secondary menu source is set as the primary menu, we display the
// second level of the primary menu.
if ($secondary_links_source == $main_links_source) {
return menu_navigation_links($main_links_source, 1);
}
else {
return menu_navigation_links($secondary_links_source, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment