I need to add an element somewhere within, or directly before/after, the main menu block. For example, the generated HTML should be something like this:
<div id="main-navigation">
<div class="block block-system" id="block-system-main-menu">
<div class="block-inner clearfix">
<div class="content clearfix">
<ul class="menu">
<li class="first expanded">
<a href="">About</a>
<ul class="menu">
<li class="first leaf">
<a href="">General Info</a>
</li>
<li class="leaf"><a href="">Video</a></li>
<!-- ... other menu items -->
</ul>
</li>
</ul> <!-- this ends the top level main ul.menu -->
<!-- a div added here would be ok -->
</div>
</div>
</div>
</div>
<!-- or a div added here would be ok -->
I am currently trying hook_block_view_alter()
and have tried multiple variations of something like this:
function theme_block_view_alter(&$data, $block) {
if ($block->delta == 'main-menu'
&& $block->region == 'menu') {
$data['content'][] = array(
'#markup' => '<div class="."><a href="#top">Close Mobile Menu</a></div>'
);
}
}
which is the closest I have come. This adds the div within ul.menu
(top level) after the last li
element; that won't work.
I can't seem to find a theming function for the menu as a whole, just theme_menu_links()
. I see the theme wrapper menu_tree__main_menu
within $data
in hook_block_view_alter()
, but I don't see a file or function that resembles that.
I'm aware that there may be a much better solution that I'm just not thinking of, so I'll state the final goal:
- Absolute positioned menu. (I can work with
#main-navigation
being absolute and the element coming after it or withul.menu
being positioned, and the element coming after it.) - A link that follows the menu in markup, but is outside of the absolute positioned menu, so that I can position relative to window, not the
ul
.
Thanks!