Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is a bit specific question but i guess it could also be used for other menu's. So before panels_everywhere i used to print out my menu like so:
print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu-ul', 'class' => array('nav'))));
I could add an additional class nav
, but now, using panels_everywhere, i cant seem to find a way to add the class. Really need it to have my theme working.
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedYou've got a couple of options!
1) Add the CSS class you need to the pane wrapper. Not ideal since in general I prefer to use the naked style on panes like this.
2) If using the 'Navigation' pane, use a preprocess to change the rendering to your liking.
3) Create a custom pane that renders exactly as you need, copying from the original pane as needed.
Comment #2
Michsk CreditAttribution: Michsk commented1) Agreed. I also like the naked style and 9 out of 10 times i even rip out all that html from those templates. Second i need that class to be on the ul (twitter bootstrap).
2) Guess it will be this option.
3) This option does not give me the option to put the class on the ul right?
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedCreating the custom pane gives you the most flexibility and the leanest markup possible because it puts you in total control.
Comment #4
Michsk CreditAttribution: Michsk commentedOk, I'll go for option 3.
Would you do it trough a custom pane with php or just programmatically? Don't know if there is any influence on caching or speed? Guess using php in a custom pane will have to go trough eval() every time so that will be slower right?
Second, i don't know if this is a bug but when i tried option two, it went 'wrong' when using the preprocess:
The template i cleaned up to only
$main_menu
, but when using the above preprocess it does not return the links, the<ul>
is shown but without the inner links.Comment #5
Michsk CreditAttribution: Michsk commentedSo im trying to get this done, here is my main_menu.inc
So now.... :-P, do i have to go as deep as you have with the pane_navigation, as in creating a whole template for this, or can i stick just to code somehow.
//edit: for those creating ctools content types, here's a good tutorial with the basics http://www.nicklewis.org/drupal/tutorials/ctools-custom-content-types
Comment #6
Michsk CreditAttribution: Michsk commentedSo this is what i would expect:
But that doesn't seem to be it.
Comment #7
Michsk CreditAttribution: Michsk commentedHere's what im doing now:
This prints what i need. Now i only need the get the class in there.
Comment #8
Michsk CreditAttribution: Michsk commentedHere's the final working code:
main_menu.inc
template.php
Comment #9
Kristen PolComment #10
RowboTony CreditAttribution: RowboTony commentedBrilliant! Thank you lasac! I'm building sites on the NodeStream distribution now and I was having trouble with this very thing, thanks for the plugin, works great!
Thanks also to Kristin for the title cleanup which allowed me to find this fix in the top search results, it's the little things that make big differences, that's why I love this community!
Comment #11
DamienMcKennaThanks for the example code, Lasac!