Hey guys I am just looking for help with my page tpl file.... I understand after researching that I need to add code to a specific region in the file I am unsure of what to exactly implement (code) wise and am wondering if someone can show me where and what to put in.

What I am trying to do is create a new region in the menu bar region as my theme does not currently have a block in my desired region. I need to create this region because I am using the "Mega Menu" module and this for obvious reasons needs to be placed on the menu bar location.. right now I just kind of have it in a different region which looks awful because there are two menu bars ( default menu & mega menu)

I am a drupal newbie and am looking very forward to completing my website but am unfortunately am pretty slow as I'm still exploring and having to watch a lot of youtube videos to learn properly... but I am learning! last time I tried to youtube it and look for info online my site ended up looking like a hurricane went through.

Below I will include the code of my file for you guys to view.. if you can kindly look at it for me and explain to me where to put the new code it would be much appreciated.

div id="page-wrapper">


<?php if ($logo): ?>
  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
    <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
<?php endif; ?>

<?php if ($site_name || $site_slogan): ?>
  <div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>

    <?php if ($site_name): ?>
      <?php if ($title): ?>
        <div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
            <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
      <?php else: /* Use h1 when the content title is empty */ ?>
        <h1 id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
          <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
      <?php endif; ?>
    <?php endif; ?>

    <?php if ($site_slogan): ?>
      <div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
        <?php print $site_slogan; ?>
    <?php endif; ?>

  </div> <!-- /#name-and-slogan -->
<?php endif; ?>

<?php print render($page['header']); ?>

<?php if ($main_menu): ?>
  <div id="main-menu" class="navigation">
    <?php print theme('links__system_main_menu', array(
      'links' => $main_menu,
      'attributes' => array(
        'id' => 'main-menu-links',
        'class' => array('links', 'clearfix'),
      'heading' => array(
        'text' => t('Main menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
    )); ?>
  </div> <!-- /#main-menu -->
<?php endif; ?>

<?php if ($secondary_menu): ?>
  <div id="secondary-menu" class="navigation">
    <?php print theme('links__system_secondary_menu', array(
      'links' => $secondary_menu,
      'attributes' => array(
        'id' => 'secondary-menu-links',
        'class' => array('links', 'inline', 'clearfix'),
      'heading' => array(
        'text' => t('Secondary menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
    )); ?>
  </div> <!-- /#secondary-menu -->
<?php endif; ?>

<?php if ($breadcrumb): ?>
  <div id="breadcrumb"><?php print $breadcrumb; ?></div>
<?php endif; ?>

<?php if ($page['sidebar_first']): ?>
  <div id="sidebar-first" class="column sidebar"><div class="section">
    <?php print render($page['sidebar_first']); ?>
  </div></div> <!-- /.section, /#sidebar-first -->
<?php endif; ?>

<div id="content" class="column"><div class="section">
  <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
  <a id="main-content"></a>
  <?php print render($title_prefix); ?>
  <?php if ($title): ?>
    <h1 class="title" id="page-title">
      <?php print $title; ?>
  <?php endif; ?>
  <?php print render($title_suffix); ?>
  <?php if ($tabs): ?>
    <div class="tabs">
      <?php print render($tabs); ?>
  <?php endif; ?>
  <?php print render($page['help']); ?>
  <?php if ($action_links): ?>
    <ul class="action-links">
      <?php print render($action_links); ?>
  <?php endif; ?>
  <?php print render($page['content']); ?>
  <?php print $feed_icons; ?>

</div></div> <!-- /.section, /#content -->

<?php if ($page['sidebar_second']): ?>
  <div id="sidebar-second" class="column sidebar"><div class="section">
    <?php print render($page['sidebar_second']); ?>
  </div></div> <!-- /.section, /#sidebar-second -->
<?php endif; ?>

<?php if ($page['footer_firstcolumn'] || $page['footer_secondcolumn'] || $page['footer_thirdcolumn'] || $page['footer_fourthcolumn']): ?>
  <div id="footer-columns" class="clearfix">
    <?php print render($page['footer_firstcolumn']); ?>
    <?php print render($page['footer_secondcolumn']); ?>
    <?php print render($page['footer_thirdcolumn']); ?>
    <?php print render($page['footer_fourthcolumn']); ?>
  </div> <!-- /#footer-columns -->
<?php endif; ?>

<?php if ($page['footer']): ?>
  <div id="footer" class="clearfix">
    <?php print render($page['footer']); ?>
  </div> <!-- /#footer -->
<?php endif; ?>

Create Region in theme .info file like this:-

regions[mega_menu]  = Mega Menu

now clear the cache of your site

After that checkout your menu block in structure blocks.
As Drupal automatically creates the blocks for menus And then assign  that menu block to the region  'Mega Menu'.

After assigning render in on page.tpl.php file like this :-

<?php if ($page['mega_menu']): ?>
    <?php print render($page['mega_menu']); ?>
<?php endif; ?>
| improve this answer | |
  • Hey thank you TB.. I have done all that and the block region demonstrates a region directly below the menu bar now so the "mega menu" is sitting right below not yet covering up the menu bar – user34253 Jul 19 '14 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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