I am sure this topic has been seen many times so I apolgize for sounding like a broken record in these forums.

I am trying to implement a CSS only drop-down menu for a Drupal site. I am fairly new to Drupal but I am not new to PHP/CSS/HTML.

I found the following code in the changeme theme which I will use as an example:

			<div id="nav">
				<?php if (isset($primary_links)) : ?>
          			<?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
        		<?php endif; ?>
			</div>

From what I understand this uses the includes/theme.inc and spits out an unordered list of links and lets you specify the class for appropriate styling. This is perfect, however the issue I see is the next step - spitting out the results for the drop down menus themselves.

The code I need for the drop down CSS menu would look like this:

<ul>
   <li><a href="link">Menu Button</a>
       <ul>
       <li><a href="link2">Drop Down Menu Option</a></li>
       </ul>
   </li>
</ul>

The trouble I have is this: I don't think I will have any problem getting the primary links to be my "menu buttons" from my sample code but how would I output the child menus into an array that I can format like this?

Hope this makes sense, thanks for any help!

Comments

nevets’s picture

Are you aware there are modules that already implement css only drop menu, nice menus being one example.

adamscottmartin’s picture

Yes I am aware that they exist, however I want to use my own with no javascript (Nice Menus claims to use a small amount of js).

Jeff Burnz’s picture

Then use ye old Suckerfish, no js required, only uses js for IE6 which won't render your CSS only menu correctly without it, if you dont care about IE6, happy days. No idea why you have an issue with JavaScript, apart massively from improving the usability of drop menus, not to mention eye candy features, it can degrade gracefully.

To answer you question though, why bother? Just use a regular menu block with parent/child items expanded, works a charm - the expanded classes are very useful;) See Pixture Reloaded theme (uses Superfish), Newswire or Tapestry themes (use suckerfish) for examples.