[development] The menu - does it have to be different on each page?

Larry Garfield larry at garfieldtech.com
Wed Aug 30 00:21:40 UTC 2006


On Tue, August 29, 2006 6:12 pm, Nedjo Rogers said:
>> Couldn't we always render the complete menu and only hide the pieces we
>> don't want to show through some CSS/JS?
>
> It would be a good performance boost not to have to rerender the menu for
> every page.
>
> There might be usability benefits too. There have been various attempts to
> get a fully rendered menu tree for usability purposes, so that we can have
> expandable tree menus, avoiding the need for frequent page reloads, see
> e.g.
> the nice_menus module and my patch to this closed issue
> http://drupal.org/node/29551, which did some of what might be needed.
>
> Making a single menu work on all pages should be simple enough with css
> and
> js. But with just css? We'd need to figure out some trick to get our
> 'expanded' and 'collapsed' classes to recognized the current location. No
> brilliant idea comes immediately to mind. Anyone else?

The only way I know of requires knowing the full list of possible
expandable entries in advance.  That means either auto-generated CSS in
the page itself, or an extremely large CSS setup, or both.

However, that said:

<body id="path_a">
<ul>
  <li class="leaf">Foo</li>
  <li class="expandable path_a">A
    <ul>
      <li class="leaf">Foo</li>
    </ul>
  </li>
  <li class="expandable path_b">B
    <ul>
      <li class="leaf">Foo</li>
    </ul>
  </li>
<ul>
</body>

.expandable {
  display: none;
}

#path_a .path_a,
#path_b .path_b {
  display: block;
}

Building up the list of ids and classes for that last rule, though, would
be difficult if not impossible.  Maybe just impractical.

OK, I'll toss the above (untested and off the cuff) snippet out in case
anyone else has a different brilliant idea. :-)

--Larry Garfield



More information about the development mailing list