I would like to make a 2-level navigation with Drupal 4.7.0b4 with a primary horizontal menu at the top and a secondary vertically to the left of the screen. I don't want the 1st-level entries to appear on the 2nd-level menu. I tried a lot of things but nothing worked. How would you approach the problem?

Comments

slazenger’s picture

linulo, i'm not sure what theme you are using, but usually primary and sec links are configured as to rendered as unordered lists, (ul, li, business) horizontally or vertically. To push the sec links on th left, you could look

a) Locate the page.tpl.php file in your theme folder and find the line that start the rendering of the left sidebar. This is usually a

or some such block invocation. You could manually code in your links box there to test and see how it works, using the CSS definitions already in use.

b) alternative, a cleaner way would be to use the menu and blocks feature. Create a Menu for your sec links and add each of your sec links as child "menu items". In the blocks configuration screen, you can then enable the Menu and float it to the left side top by setting the options. I realise this may not be what you had in mind, but it might work.

-S

linulo’s picture

Thanks for the quick answer, slazenger.

I am using a slightly modified bluemarine theme.

b) I tried this for hours, but the problem here is that I would have to manually configure the visibility for the block for every new page I add to the menu.

I am going to take a look into a) now.

/edit Hmm, nothing but
<?php print $sidebar_left ?>
and I am reluctant to touch this. On the other hand, I have code snippets here to show or hide blocks based on taxonomy terms. Maybe this could work.

linulo’s picture

I solved the problem and I would like to share what I have found out. As a fact there are at least two more ways to implement it but they need php coding. So here goes:

  • Create start pages for all of your main categories and attach them to the primary links menu. You can set up the primary links to appear horizontally on the top region.

  • Create a vocabulary and add a term for each of your main categories.

  • Install the module Taxonomy Block and create a taxonomy block for all of your main categories. Give them meaningful names like "subemenu corporate info". Bind them to the respective taxonomy term.

  • Activate the path module and install the module Pathauto. Under the Node path settings enter "[cat]/[title]".

  • Activate the taxonomy blocks in the general block administration. For every block set it to "only visible on listed pages". In the pages field enter the name of the respective taxonomy term and another line with a slash and an asterisk appended ("/*"). So if your taxonomy term is corpinfo you would enter

    corpinfo
    corpinfo/*
  • Create new pages and pick a taxonomy term. The page should appear automatically in the submenu.

How it works: The taxonomy block creates a menu of content bound to a specific taxonomy term. All we need to do is control when to display the menu. The pathauto module automaticall assigns aliases to content. We make sure every page gets an alias that reflects the taxonomy term it is bound to. This way we can set up a block visibility rule that keeps the menu block from appearing on pages that do not belong to this category.

Notes

  • As a side effect you will have (meaningful) path aliases for every new page. This is very nice in regard to search engines.

  • If you do not want the links "more" on the menus you can suppress them in your theme's style with

    .more-link {
    	font-size: 0pt;
    	visibility: hidden;
    }

Let me know if you have any questions about this mini-howto.

slazenger’s picture

I didn't realise that you wanted category sensitive menu of links on the left. Given, that, it looks like your approach is a good one.

However, if the node is categorised in multiple categories, how does the path module behave? And if so, will your secondary links
menu continue to show properly?

In my case, most of my node/articles will have more than one category. And I'm interested in putting a secondary menu on the left for article pages too.

-S

linulo’s picture

pathauto will name the alias from the category with the lowest weight. On my site there will be no conflicts because I use just a single vocabulary.

Do you know, what you want to appear in the submenues? Maybe it can be done by setting the weights accordingly.

slazenger’s picture

I'll have to try this out, but the weighting thing shows there is a method in place. I'll come back to this when I've tried to implement what I want and see what if, any, problems come up. Thanks for the input!
-S

JoshLangner’s picture

There is another solution to this problem here: http://drupal.org/node/73638

Much easier to implement for those who don't want to venture into Taxonomy yet.

johnalbin’s picture

You stated:

If you do not want the links "more" on the menus you can suppress them in your theme's style with

.more-link {
font-size: 0pt;
visibility: hidden;
}

This would work better (and it's shorter):

.more-link {
display: none;
}

  - John (JohnAlbin)