1

I noticed that you can put content pretty much anywhere ( where a theme provides regions) using blocks.

This becomes pretty straight forward and makes sense. But then I was trying to find where the "My account" and "Logout" links came from. And after some searching I found out they are configured in the Menus -> Settings admin page.

Now I read the controversy about the misleading help text for the Source for the Secondary links, so this "special" behavior to display secondary links doesn't seem to work anymore in Drupal 7.

So my question is: Why are these "regions", treated separately at all ?

Why not have normal main menu and secondary menu regions ?

5
  • very complicated.....
    – Sibiraj PR
    Commented Apr 17, 2013 at 11:46
  • It seems everyone is dodging your actual question :) - I'm not really sure why but I find it a bit annoying that they are usually coded differently, instead of being a menu block in a region.
    – rooby
    Commented Apr 22, 2013 at 13:02
  • I bet it's for some historic reasons. I wonder if Drupal 8 will still have them...
    – Ray Hulha
    Commented Apr 22, 2013 at 17:40
  • 2
    The entire block/region system is a general mess, and as you suggest, the problem is likely historic. One could dig around in the git logs and issue queue to find out, but: Just avoid it all together and use Panels in D6/7. Fortunately D8 will adopt a Panels like style to handle the problem.
    – Letharion
    Commented Apr 27, 2013 at 10:32
  • Great comment, someone finally understood the question. Looking forward to D8 then :) To bad I can't award you the bounty...
    – Ray Hulha
    Commented Apr 27, 2013 at 17:49

6 Answers 6

3

So after much research I found that the main menu and secondary menu settings are there for historical reasons. They had proper functionality in Drupal 5 but its usefulness has declined over the release of newer version ( 6 and 7 ) to the point where modern themes ignore them completely in favor of the powerful regions concept.

The included themes ( as others have mentioned ) have these special "regions" still just because no one cares to remove them.

The original idea was to have an easy way to present sub menu links ( secondary menu ) dependent on the what you select in the main menu.

The modern approach is to have a pop-out sub menu ( like Superfish ) this has made the secondary menu feature obsolete.

So much so in fact, that the functionality is broken and no one fixes it.

In summary, the feature is broken and obsolete. I hope someone removes it from Drupal 8.

1

I am afraid I can't answer your question. But the Menu Block module might be a solution to your problem.

The module can render menus in a block. It can also render a submenu for the main menu and put it in a separate block.

(If you have child menu items and the parent is the front page, you might need to patch the menu block module. Drupal does not seem to like child menu items of the front page.)

1
+50

If you make your secondary links "source" the primary links, then secondary links will automatically show the child menu items of the current active menu item / page.

Regarding menus as regions, you may be mistaking theme regions for page content.

Main menu and secondary menus are page content often placed directly within a theme region.

There's nothing to stop you putting the menus in a block wrapper for Admin > Structure > Blocks administration, then add to a theme region that way.

It just matters what best suits your site design and layouts.

e.g: put menus in blocks

/**
 * Implements hook_block
 * Provide core menus as regular blocks
 */
function example_menus_block_info(){
  $blocks['example_main_menu'] = array(
    'info' => t('example Main menu'), 
    'cache' => DRUPAL_CACHE_GLOBAL,
  );
  $blocks['primary_tabs'] = array(
    'info' => 'Local tasks: primary',
    'cache' => DRUPAL_CACHE_PER_PAGE
  );
  $blocks['secondary_tabs'] = array(
    'info' => 'Local tasks: secondary',
    'cache' => DRUPAL_CACHE_PER_PAGE
  );
  $blocks['primary_secondary_tabs'] = array(
    'info' => 'Local tasks: primary and secondary',
    'cache' => DRUPAL_CACHE_PER_PAGE
  );
  return $blocks;
}

/**
 * hook_block_view
 */
function example_menus_block_view($delta = ''){
  $block = array();
  $block['subject'] = ''; // default no title
  switch ($delta) {
    // Our own properly wrapped main menu for panels.
    case 'example_main_menu':
      $main_menu = menu_main_menu();
      $options = array(
          'links' => $main_menu,
          'attributes' => array(
            'id' => 'main-menu',
            'class' => array('links', 'inline', 'clearfix'),
          ),
          'heading' => array(
            'text' => t('Main menu'),
            'level' => 'h2',
            'class' => array('element-invisible'),
          ),
        );
      $block['content'] = theme('links__system_main_menu', $options);
    break;
  case 'primary_tabs':
    $block['content'] = array(
      '#primary' => menu_primary_local_tasks(),
      '#theme' => 'menu_local_tasks',
    );
    break;
  case 'secondary_tabs':
    $block['content'] = array(
      '#secondary' => menu_secondary_local_tasks(),
      '#theme' => 'menu_local_tasks',
    );
    break;
  case 'primary_secondary_tabs':
    // default, same as core
    $block['content'] = menu_local_tabs();
    break;
  }
  return $block;
}

Clear cache and can then add the menus as regular Drupal blocks.

1
  • Awarded this answer because he put the most work into it and I can't reward myself :)
    – Ray Hulha
    Commented Apr 27, 2013 at 17:47
0

Regions are provided by the Drupal theme.

They are declared in the .info file of theme.

I can suggest you are working with the bartik theme.

Secondary menu (like any other menu) can be printed like block or programmatically. You can find $secondary_menu variable in the /themes/bartik/templates/page.tpl.php file at line 143.

If you want to switch off secondary or main menu visit /admin/appearance/settings/ page at your Drupal site and uncheck Main menu or Secondary menu

Why not have normal main menu and secondary menu regions ?

Some themes (for example Fusion) provide special regions for menu from box. But there is no need in that because you can create you own region wherever you want with few steps:

  1. Declare region in theme .info file
  2. Print your region in page.tpl.php file of you theme
  3. Flush caches

For more details read Theming Guide and Assigning content to regions

0

If you want your menus in specific regions you can disable the main menu and secondary menu on your theme settings page.

Every menu in Drupal has a block at the block configuration page.

You can then place the menu blocks in any region you desire. I'm not sure why Drupal by default is not setup like this.

You should also be able to disable the menus when creating a new theme by not specifying it as a feature in the themes info file.

See http://drupal.org/node/171205#features

1
  • I don't want my menus in specific regions, I want to know why these special regions exist in the first place
    – Ray Hulha
    Commented Apr 25, 2013 at 11:01
0

Ray, I suspect the answer to your question is the same as to "Why isn't the logo a region?". Postings such as Display a block next to the Logo show that this causes confusion too.

I suspect that in the original Drupal, themes were much simpler. Drupal's authors could have just provided a content area, plus special-purpose spaces such as those for the logo and the two menus, which were enough to implement their original idea of a Web page. Maybe there were no regions yet, but someone then realised that these special-purpose spaces could be generalised thereto.

Most readers will be familiar with the way that programmers implement something and then realise that various special-purpose features can be generalised. Since StackExchange asks for facts rather than opinions, I searched for stuff about how Drupal developed, but found nothing relevant (though I suppose I could look at the code archives). I see from Evolution of Drupal and the Drupal community - SlideShare that Drupal 4.7.0 already had blocks. And that the first Drupal had only a couple of dozen themes, "all ugly".

By the way, I've been experimenting with Devsaran's Venture theme, and that appears to depend on these abnormal non-regions. So they're still used in at least one modern theme. I described my experiences with it at Why can themes (Venture, but perhaps others too) display a main menu even when the main-menu block is disabled?, where I also referred to your answer to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.