How can I have the primary navigation menu shown in the header block in full, with all dropdown elements available?
Accepted answer
Comments
I don't think that's possible. Not sure if there is a contrib module that could provide this.
I found a way with a custom module:
function bootstrap_header_block_view_system_header_alter(&$data, $block) {
$data['content'] = bootstrap_header_header_block_content();
}
function bootstrap_header_header_block_content() {
$settings = array(
'logo' => TRUE,
'site_name' => TRUE,
'site_slogan' => TRUE,
);
$settings_block = array(
'menu_name' => 'main-menu',
'style' => 'dropdown',
'level' => 1,
'depth' => 0,
);
module_load_include('inc', 'system', 'system.menu');
$block = system_menu_block_build($settings_block);
$site_config = config('system.core');
$variables['logo'] = $settings['logo'] ? backdrop_get_logo() : NULL;
$variables['logo_attributes'] = $settings['logo'] ? array_diff_key(backdrop_get_logo_info(), array('path' => '')) : array();
$variables['site_name'] = $settings['site_name'] ? check_plain($site_config->getTranslated('site_name')) : '';
$variables['site_slogan'] = $settings['site_slogan'] ? filter_xss_admin($site_config->getTranslated('site_slogan')) : '';
$variables['menu'] = backdrop_render($block['content']);
return theme('header', $variables);
}
I found a way with a custom module:
function bootstrap_header_block_view_system_header_alter(&$data, $block) { $data['content'] = bootstrap_header_header_block_content(); } function bootstrap_header_header_block_content() { $settings = array( 'logo' => TRUE, 'site_name' => TRUE, 'site_slogan' => TRUE, ); $settings_block = array( 'menu_name' => 'main-menu', 'style' => 'dropdown', 'level' => 1, 'depth' => 0, ); module_load_include('inc', 'system', 'system.menu'); $block = system_menu_block_build($settings_block); $site_config = config('system.core'); $variables['logo'] = $settings['logo'] ? backdrop_get_logo() : NULL; $variables['logo_attributes'] = $settings['logo'] ? array_diff_key(backdrop_get_logo_info(), array('path' => '')) : array(); $variables['site_name'] = $settings['site_name'] ? check_plain($site_config->getTranslated('site_name')) : ''; $variables['site_slogan'] = $settings['site_slogan'] ? filter_xss_admin($site_config->getTranslated('site_slogan')) : ''; $variables['menu'] = backdrop_render($block['content']); return theme('header', $variables); }