Hi,
I've been adopting a custom html template to a Drupal theme. The theme included a navigation menu (one level only) on the left. I created a new menu with all the corresponding menu items, activated through the blocks page, however now I want to style it the way it was in the template. I've searched for a while, but did not find something appropriate. Which function should I override to accomplish what I want? Besides the primary and secondary links, how do I have access (through variables maybe) to the other menus inside a PHPTemplate page?
Thanks,
It depends on what styling you need to do. You can do a lot with css and should try that route first. You can figure out which css to add or alter by viewing source and seeing which classes and ids are being used. You likely only have to edit functions if the menu is showing the wrong elements, for example if it is showing children that you don't want shown. If it's presnting the correct elements but in the wrong way you can probably fix it with css.
Vasileios Lourdas wrote:
Hi,
I've been adopting a custom html template to a Drupal theme. The theme included a navigation menu (one level only) on the left. I created a new menu with all the corresponding menu items, activated through the blocks page, however now I want to style it the way it was in the template. I've searched for a while, but did not find something appropriate. Which function should I override to accomplish what I want? Besides the primary and secondary links, how do I have access (through variables maybe) to the other menus inside a PHPTemplate page?
Thanks,
On Wednesday 19 September 2007 16:07:05 sander-martijn wrote:
It depends on what styling you need to do. You can do a lot with css and should try that route first. You can figure out which css to add or alter by viewing source and seeing which classes and ids are being used. You likely only have to edit functions if the menu is showing the wrong elements, for example if it is showing children that you don't want shown. If it's presnting the correct elements but in the wrong way you can probably fix it with css.
OK, thanks for your suggestions. Drupal renders the code like this:
<ul class="menu"> <li class="leaf"><a href="...">Schools</a></li> <li class="leaf"><a href="...">Parents</a></li> ... </ul>
So, I have to edit the menu and leaf classes in css. However, if I want to go further, how do I have access to the menu structure through PHP?
You'll want to look at the enclosing divs above that first - if you edit the classes for menu and leaf it will apply to all menus that use the menu and leaf classes.
What you need to do beyond that depends really on what you want to do. For example I have one menu that just uses css, one menu that uses the nice_menus module which I then modified the css for, and one completely custom menu that's written in straight php in my template and looks like this: $trail = _menu_get_active_trail(); $mid = $trail[1]; if($mid != 5){ $output .= theme('menu_item', $mid); $output.= theme('menu_tree',$mid); print('<ul class="leftnavmenu">'); print $output; print('</ul>');
So there is no correct answer - it all depends on what exactly you're trying to do.
Vasileios Lourdas wrote:
On Wednesday 19 September 2007 16:07:05 sander-martijn wrote:
It depends on what styling you need to do. You can do a lot with css and should try that route first. You can figure out which css to add or alter by viewing source and seeing which classes and ids are being used. You likely only have to edit functions if the menu is showing the wrong elements, for example if it is showing children that you don't want shown. If it's presnting the correct elements but in the wrong way you can probably fix it with css.
OK, thanks for your suggestions. Drupal renders the code like this:
<ul class="menu"> <li class="leaf"><a href="...">Schools</a></li> <li class="leaf"><a href="...">Parents</a></li> ... </ul>
So, I have to edit the menu and leaf classes in css. However, if I want to go further, how do I have access to the menu structure through PHP?
How do I figure out which of the style sheets I need to modify for any given element and in what order they are applied? My theme (aberdeen) has several and some elements have bits of css on more than one style sheet. I made changes in one place and they don't always seem to "take."
Should I need to modify the system.css and others or just the style.css? Will it cause problems if I modify the system.css or others?
Jean
On 9/19/07, Vasileios Lourdas lourdas_v@yahoo.gr wrote:
On Wednesday 19 September 2007 16:07:05 sander-martijn wrote:
It depends on what styling you need to do. You can do a lot with css and should try that route first. You can figure out which css to add or alter by viewing source and seeing which classes and ids are being used. You likely only have to edit functions if the menu is showing the wrong elements, for example if it is showing children that you don't want shown. If it's presnting the correct elements but in the wrong way you can probably fix it with css.
OK, thanks for your suggestions. Drupal renders the code like this:
<ul class="menu"> <li class="leaf"><a href="...">Schools</a></li> <li class="leaf"><a href="...">Parents</a></li> ... </ul>
So, I have to edit the menu and leaf classes in css. However, if I want to go further, how do I have access to the menu structure through PHP? -- # Vasileios Lourdas, # Informatics Engineer, Thessaloniki (Greece)
# http://www.lourdas.name
[ Drupal support list | http://lists.drupal.org/ ]
Jean Gazis wrote:
How do I figure out which of the style sheets I need to modify for any given element and in what order they are applied? My theme (aberdeen) has several and some elements have bits of css on more than one style sheet. I made changes in one place and they don't always seem to "take."
To dissect CSS, try this: http://chrispederick.com/work/web-developer/ for FireFox. You can examine elements in detail and edit CSS in real time to see the effects.
Should I need to modify the system.css and others or just the style.css? Will it cause problems if I modify the system.css or others?
Yes, I wouldn't modify any system files. Try to just add CSS rules more specific than the system ones and then yours will take precedence.
Fred
Your theme should be in /sites/all/themes/. You should only modify files in the chosen theme. Generally if there are more css files than style.css in your theme folder then they're for specific sections/pages. In almost all cases you want to put your styles at the bottom of style.css - especially if it's for something global like navigation. It's quite possible any other css files are not included on all pages.
Usually if you're putting css at the end of style.css and it's not working you need to try a different set of selectors - eg from below if li.leaf doesn't work, try ul li.leaf or ul.menu li.leaf - but as I said before you probably want to be more specific than any of those suggestions because you don't want to affect your other menus, the admin menu etc - and most menus use the menu, leaf, expanded and collapsed tabs.
As an example - I have in my style.css (which is an entirely custom theme so I don't know whether it will work for you at all or not, this is just an example) ul.leftnavmenu .leaf, ul.leftnavmenu .collapsed, ul.leftnavmenu .expanded{ list-style:none; background:none; }
which removes all decorations from all menus - because I didn't want them.
Jean Gazis wrote:
How do I figure out which of the style sheets I need to modify for any given element and in what order they are applied? My theme (aberdeen) has several and some elements have bits of css on more than one style sheet. I made changes in one place and they don't always seem to "take."
Should I need to modify the system.css and others or just the style.css? Will it cause problems if I modify the system.css or others?
Jean
On 9/19/07, * Vasileios Lourdas* <lourdas_v@yahoo.gr mailto:lourdas_v@yahoo.gr> wrote:
On Wednesday 19 September 2007 16:07:05 sander-martijn wrote: > It depends on what styling you need to do. You can do a lot with css > and should try that route first. You can figure out which css to add or > alter by viewing source and seeing which classes and ids are being > used. You likely only have to edit functions if the menu is showing the > wrong elements, for example if it is showing children that you don't > want shown. If it's presnting the correct elements but in the wrong way > you can probably fix it with css. OK, thanks for your suggestions. Drupal renders the code like this: <ul class="menu"> <li class="leaf"><a href="...">Schools</a></li> <li class="leaf"><a href="...">Parents</a></li> ... </ul> So, I have to edit the menu and leaf classes in css. However, if I want to go further, how do I have access to the menu structure through PHP? -- # Vasileios Lourdas, # Informatics Engineer, Thessaloniki (Greece) # http://www.lourdas.name -- [ Drupal support list | http://lists.drupal.org/ ]-- Jean Gazis www.jeangazis.com http://www.jeangazis.com www.boxofrain.us http://www.boxofrain.us
"Believe those who are seeking the truth; doubt those who find it." - André Gide
OK, continuing the thread (although not completely relevant to the initial post), I've successfully themed the menu as I see fit. Now, I want to include a block.tpl.php file to theme blocks. The code I put inside is:
<table width="200" border="0" cellspacing="0" cellpadding="0" class="blocktbl"> <tr> <td class="blockhdng"><?php echo $block->$subject; ?></td> </tr> <tr> <td valign="top" class="blockelem"><?php echo $block->$content; ?></td> </tr> <tr> <td class="blockbtm"> </td> </tr> </table>
However, now the menu has disappeared and the block appears empty in the menu's position. If I rename block.tpl.php to something else, the menu appears again.
I don't want the menu to appear inside a block and I want it to have the style I set it. What happens when I put block.tpl.php in the game?
Thanks.
On 9/21/07, Vasileios Lourdas lourdas_v@yahoo.gr wrote:
OK, continuing the thread (although not completely relevant to the initial post), I've successfully themed the menu as I see fit. Now, I want to include a block.tpl.php file to theme blocks. The code I put inside is:
<table width="200" border="0" cellspacing="0" cellpadding="0" class="blocktbl"> <tr> <td class="blockhdng"><?php echo $block->$subject; ?></td> </tr> <tr> <td valign="top" class="blockelem"><?php echo $block->$content; ?></td>
You mean $block->subject and $block->content
</tr> <tr> <td class="blockbtm"> </td> </tr></table>
However, now the menu has disappeared and the block appears empty in the menu's position. If I rename block.tpl.php to something else, the menu appears again.
I don't want the menu to appear inside a block and I want it to have the style I set it. What happens when I put block.tpl.php in the game?
Thanks.
# Vasileios Lourdas, # Informatics Engineer, Thessaloniki (Greece)
# http://www.lourdas.name
[ Drupal support list | http://lists.drupal.org/ ]
On Friday 21 September 2007 07:10:45 Cog Rusty wrote:
You mean $block->subject and $block->content
Oops!! Right! Sorry for that.
Now the menu appears, but Drupal renders it inside a block (as it should of course). However, I don't want that, I want the specific menu to appear without the outside border (the block theming stuff). How can I do that?
Any help will be greatly appreciated...
Now the menu appears, but Drupal renders it inside a block (as it should of course). However, I don't want that, I want the specific menu to appear without the outside border (the block theming stuff). How can I do that?
A file named block-menu.tpl.php will apply to menu blocks only. Use block.tpl.php content as a starting point. Once you have the file, you can put in any framing HTML you want, or none at all.