Hi all,

I'm a really new to php and I have a question about calling a variable, that is used in the Zen theme, directly into a block.

I noticed that in the Zen page.tpl.php the primary links menu is called like this: print theme('links', $primary_links);
I'd like to do exactly what that does, but in a block. I have the optional core php module turned on, and the input format on the block is set to php. I tried pasting that php code directly into my block and nothing prints.

Is it possible to call this function in a block, am I on the right track? I don't even know if it's a core Drupal function or something that Zen owns.

Thanks,
~Lindsay

More background about what I'm trying to do, in case it helps troubleshoot: I'd like to print the primary links in the header of the Zen theme. By default page.tpl.php prints it below the header. I could just edit the page.tpl.php (copying it to my sub-theme folder first, of course), but I'd rather avoid editing the template files if possible, that way when Zen is updated I'll get the biggest possible benefit. So instead I figured I could print the primary links in a block and put that block in the header. I don't want to use the Drupal primary links block because it prints them vertically, I would like the links to run horizontally, which the $primary_links variable seems to do.

Comments

hualahyja’s picture

On the block management page, there is a block ready for every menu in the system. So it is for the Primary Links menu.
Let's check the admin/build/block page and assign the Primary Links block to the Header region.

Then, in the theme settings page - ucheck the display of primary links, on your zen theme settings.

lindsay’s picture

Thanks for replying. Though as I said above, the default Drupal system blocks won't work for me because I want the menus to run horizontally, not vetically like the ones you sugest. Thanks again though. Any other suggestions?

hualahyja’s picture

You can edit css of your theme for this particular menu.

The li's in the menu ul have to be floated left or right.
Use firebug to find out the id of the ul.menu element and set all the li's float property to float: left;

lindsay’s picture

Super! This is a great suggestion. I'm much more competent with CSS than php. Thanks so much for the suggestion, and for the follow up after that.

lindsay’s picture

Again, thank you. I wanted to let you know that I implemented this solution and it works wonderfully.

Here is the CSS I used, less for you, hualahyja, and more for the archives and other users that might be interested.

/** float right to line up horizontally on the right, margin 10 to give enough space for the bullets **/
#block-menu-primary-links li{
float: right;
margin: 0 10px;
}

/** don't display the tile of the block, in this case "Primary Links" **/
#block-menu-primary-links h2.title {
display: none;
}

hualahyja’s picture

I'm glad to read you were succesful.

You can also hide the block title by disabling it on block admin page--just set the block title to '' (without apostrophes).