Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: Using of Primary/Secondary Links for Building of Split-Level Menu

Submitted by on April 30, 2010 – 8:25 amNo Comment

 

You need:

  • Create split-level menu.
  • The upper string is main items (first level), and sub-menu appears to the left of the selected item.
  • Parent item from main menu items is active when navigation through submenus.


Solution:

We need to form one menu creating its structure through selection of parent items, and then make the same menu primary and secondary in menu settings and add location of these menus in the form of ‘links’in  page.tpl.php.

Please follow step-by-step instructions to do this::

  1. GO to Administer → Site Building → Menus
  2. Create menu (you can create the required items just in primary links – menu is already created by default). To make menu split-level, select parents for menu items. Do nor create 2 different menus.
  3. Open Settings tab and select:
    Menu with primary links: your menu (Primary links)
    Menu with secondary links: your menu (Primary links)
  4. Insert the following code to page.tpl.php:
    For primary_links

<?php if (isset($primary_links)) { ?><?php print theme(‘links’, $primary_links) ?><?php } ?>

          For secondary_links:

<?php if (isset($secondary_links)) { ?><?php print theme(‘links’, $secondary_links) ?><?php } ?>

This method can be used for two-level hierarchy i.e. there are upper items and left items. No other submenus – secondary menu won’t show them.

We will use TemplatePHP  snippet from this page to create parent link with class="active". Insert the following code (without closing ?>) to template.php.

<?php
function phptemplate_links($links, $attributes = array()) {
  if (!count($links)) {
    return ”;
  }
  $level_tmp = explode(‘-‘, key($links));
  $level = $level_tmp[0];
  $output = "<ul class=\"links-$level ".$attributes[‘class’]. "\">\n";
  foreach ($links as $index => $link) {
    $output .= ‘<li';
    if (stristr($index, ‘active’)) {
      $output .= ‘ class="active"';
    }// frontpage AND current-link in menu is <front>
    elseif((drupal_is_front_page()) && ($link[‘href’]=='<front>’)){
      $link[‘attributes’][‘class’] = ‘active';//add class active to <li
      $output .= ‘ class="active"';//add class active to <a
    }
    $output .= ">". l($link[‘title’], $link[‘href’], $link[‘attributes’], $link[‘query’], $link[‘fragment’]) ."</li>\n";
  }
  $output .= ‘</ul>';
  return $output;
}
?>

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.