Hello I have a javascript type Menu (Primary Links) that display when hovered a Submenu (Secondary Links) based on the rel option like this:
//Primary Menu Links

<div id="menu">
<ul>
              <li><a href="#" rel="gc1"><span>LINK1</span></a></li>
              <li><a href="#" rel="gc2"><span>LINK2</span></a></li>
              <li><a href="#" rel="gc3"><span>LINK3</span></a></li>
              <li><a href="#" rel="gc4"><span>LINK4</span></a></li>
              <li><a href="#" rel="gc5"><span>LINK5</span></a></li>
              <li><a href="#" rel="gc6"><span>LINK6</span></a></li>
</ul>
</div>

//Secondary Menu is based on the rel option of primary links:

          <div class="tabcontainer">
            <div id="gc1" class="tabcontent">
              <p><a href="#">SUBLINK11</a>|<a href="#">SUBLINK12</a></p>
            </div>
            <div id="gc2" class="tabcontent">
              <p><a href="#">SUBLINK21</a>|<a href="#">SUBLINK22</a>|<a href="#">SUBLINK23</a></p>
            </div>
            <div id="gc3" class="tabcontent">
              <p><a href="#">SUBLINK31</a>|<a href="#">SUBLINK32</a>|<a href="#">SUBLINK33</a>|<a href="#">SUBLINK34</a>|<a href="#">SUBLINK35</a>|<a href="#">SUBLINK36</a>|<a href="#">SUBLINK37</a></p>
            </div>
            <div id="gc4" class="tabcontent">
              <p><a href="#">SUBLINK41</a>|<a href="#">SUBLINK42</a>|<a href="#">SUBLINK43</a></p>
            </div>
            <div id="gc5" class="tabcontent">
              <p><a href="#">SUBLINK51</a>|<a href="#">SUBLINK52</a>|<a href="#">SUBLINK53</a></p>
            </div>
            <div id="gc6" class="tabcontent">
              <p><a href="#">SUBLINK61</a></p>
            </div>
          </div>

It seems that foreach is not useful...do you have a solution how to make a for to cycle this?

Thank you

Comments

Jeff Burnz’s picture

I did a quickie modification to theme_links, http://api.drupal.org/api/function/theme_links

Perhaps a hardcore programmer can suggest something more, I'm more of a part timer:)

I dropped the span tags in there also.

function MYTHEME_links($links, $attributes =  array('class' => 'links')) {
  $output = '';
  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;
    
    // set a variable to increment
    $x = 1;
 
    foreach ($links as $key => $link) {
      $class = $key;
      
      // set a variable to print our rel attribute
      $rel = 'rel="gc'. $x++ . '"';

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
        $class .= ' active';
      }
						
      // include the new rel variable in the output
      $output .= '<li'. drupal_attributes(array('class' => $class)) .' '. $rel .'>';

      if (isset($link['href'])) {
        $link['title'] = '<span>' . check_plain($link['title']) . '</span>';
        $link['html'] = TRUE;     
        // Pass in $link as $options, they share the same keys.
        $output .= l($link['title'], $link['href'], $link);       
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</li>\n";
    }

    $output .= '</ul>';
  }
  return $output;
}
gingic’s picture

This project is my own personal first drupal one, I will surely test it the menu and let you see how it looks like. Thank you I really appreciate your efforts

Jeff Burnz’s picture

I forgot to mention there is also the Nice menus module, and the jquery plugin "Superfish" is pretty easy to get working in Drupal, take a look at the Pixture Reloaded theme for an example.

gingic’s picture

I have now idea how to use the function.
however i am pretty confused because the primary links load in a first set of div while secondary links in another one like this:


          <div id="ddtabs" class="glowingtabs">
            
--primary links here
 
			
          </div>


          <div class="tabcontainer">
--secondary links here
          </div>
       

I have failed tried to make the menu work... i have tried to call the function from the page.tpl.php like in many ways smth like this:

<?php if (isset($primary_links)) : ?>
          <?php print MYTHEME_links('links', array('class' => 'links primary-links')) ?>
        <?php endif; ?>

maybe you can help me get out of this confusion.. i will endup using superfish but it does do the same thing and i am afraid i will face the same problem.

Thanks a lot

gingic’s picture

it seems the Superfish is a nice option. I am using now the Pixture Reloaded Theme which has Superfish dropdown menu. I can alter it to make it nav-bar style as I needed just doing 2 things:

1. Adding superfish-navbar class...DONE
2. Adding sf-navbar class to the ul that builds up the menu...here i got stuck for i cannot find where the

    is found at the theme level? Can you show me where this
      ?
      If I found it this issue is fixed
      Thank you