0

I want to alter the HTML of the main menu. I have a manu set up with text-align: justify.
Now in Chrome, the whitespace between the last li and ul is rendered as 4px, making the last item not aligned to the right margin. See this stackexchange post. I want to remove the whitespace or replace it with and html comment.
I am a bit lost ;-). What should I be overriding? theme_menu_tree?
I am using the Omega 3.

1 Answer 1

1

Because it sounds like your question is really about how to manipulate the main menu markup in Omega, I guess I'll focus on that. That said however, the "whitespace" issue from the post that you reference is quit strange, as I'm not sure I understand how a newline between an closing li and ul tag would influence any visible alignment behavior. I'm also not sure that Omega even adds any such newlines to the menu output by default. Still, it sounds like you've isolated this as a cause already.

If you are using the main menu that's automatically inserted within the page by Omega (as opposed to displaying your main menu via a menu block or similar), then I believe the most specific theme hook that applies is 'links__system_main_menu'. Check out the omega/omega/templates/region--menu.tpl.php theme file to see how this is ultimately called.

It's important to note however that 'links__system_main_menu' is not necessarily a hook that you'll find an existing theme function for, it's just a suggested pattern. See this post for more on that. Chances are the theme function that's actually getting used currently is theme_links(), or in the case of Omega (which already has an override setup) omega_links().

So if you want to target an override that's specific to just the main menu you could use the code from omega_links() as a template for your own override called MYTHEMENAME_links__system_main_menu(). Then within this new function you could adjust the output to tweak the way "whitespace" is added before and after any ul and li tags as you deem necessary.

4
  • wow, thanks for such an extensive answer. I'll be working that out very soon.
    – Dalmaz
    Commented Jan 10, 2015 at 23:54
  • I'm trying to apply your suggestions. It uses the omega_links function from omega.theme.inc. I copied the code from that function to MYTHEME_links() in the template.php of my file and it's being overridden. So far so good...
    – Dalmaz
    Commented Jan 11, 2015 at 20:00
  • ...but the main menu that goes through blocks (not rendered automatically by means of primary / secondary links) does not go through that 'theme_links' function...
    – Dalmaz
    Commented Jan 11, 2015 at 22:38
  • 1
    Yeah, for a menu in a block the theme stuff is a bit different. For that I think the hook that applies is 'menu_link'. See this post for more on that. That might actually make more sense within the context of this problem as the default theme_menu_link() puts a newline (\n) after each li, which would seem to correlate with the core issue you have identified. So if you override that function you might just have to remove the \n part.
    – rjacobs
    Commented Jan 12, 2015 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.