Hi Drupal Gurus
I've searched through drupal.org, google, handbooks, and other themes but can't find an example of this - although others have asked the question. I'm fairly new to drupal theming.
I'd like to have my theme have a menu in the footer region that is horizontal with "|" separating the menu items. I'd like to build this into my theme, as opposed to hard coding anything dependent (like mid) upon my site. I'm using the zen theme as a base.
I have a region called 'footer', so I would imagine I would create a block-footer.tpl.php, which will allow me to format the footer block html. What I can't figure out is how to format the individual menu/menu items. Right now they are in a variable called $block->content. Where is this formatted and how can I override it?
I'd like any menu that is in the footer region to be formatted this way (without hardcoding the menu IDs).
Thanks in advance,
mojobaer
p.s. a quick bonus newbie (php?) question: how do I find out what variables are available in drupal functions? I noticed in theme_menu_tree that only $pid is passed in, but there is a conditional statement checking $tree. I would love to be able to look at $vars, but it doesn't seem available. Boy, can you tell I'm a newbie to this yet?
Comments
You can configure your
You can configure your footer in site settings Site configuration > Site information. You can enter html in the footer info :0)
True....but...
Yup, true, thanks.
But I'd like to use the power of the themed drupal menus - be able to have a nice menu set up and assign it to the footer block and have it formatted horizontally with "|" dividers, rather than hardcoding the html in settings. I could also just code the menu up the css, but I'd rather not hardcode the block number. By having it in the theme, it can then be used on many sites. Ah the power of themes (if I could just figure this out)!
Drupal has built in functions to do this
See http://api.drupal.org for the list of functions but basically put this code into your block-footer.tpl.php
print theme('links', menu_primary_links(0,$block->delta));There is an article with full instructions on how to do exactly this on my site:
http://www.xweb.com.au/display_menu_horizontal_region
-- Chris Herberte
Thanks for the info on this.
Thanks for the info on this. A big help. Is there anyway to center the links to the footer BTW???
Centering
I'm having the same problem. The links don't seem to respond to {text-align:center}
Centering content...
You probably have figured out an answer to this by now, but if not, here you go.
I have not done this (in this context), but this should work and should also be compatible with all browsers.
the margin-left:auto and margin-right:auto will center the content in firefox type browsers and the text-align:center; will center it in IE type browsers. You have to put the div around it because the content in the div will be centered (not the element its self).
Hope this helps...
It seems the centering
... wont work. Ive added this code into my block-footer.tpl.php but it just won't center - still sticks left on the footers border ... has anyone found out, why this wont work?
couple things to check...
make sure the div that you are putting your menu system in is a 'block' and is not 'inline' because you want that div to be the entire width of the area. if it is inline then it will only be as big as the content and it will get pushed around based on its container (which is text-align:left im sure)...
i would recommend looking at the output in firefox with firebug enabled so you can see how the css is being rendered and see if there is something in the menu system its self that is pushing it left.
i know the code above works because i tested it independently of your situation. you need to figure out with firebug what is causing the problem because it probably depends a lot on your theme.
need a seperator
This works great but I need a separator. For example I want to change the following display:
Home Contact Us Privacy Policy Terms & Conditions
to
Home | Contact Us | Privacy Policy | Terms & Conditions
Separator
Did you manage to find solution for your "separator" problem?
The problem with creating
The problem with creating "block-footer.tpl.php" and inserting code mentioned above you will not be able to add any other blocks in to the footer.
Menus are a breeze with drupal 6
print theme('links', menu_navigation_links('menu-foooter'));
menu-foooter is the name of the menu. Everytime u make a new menu its prefixed by 'menu-'
The line above does everything.