I'm sitting here staring blankly at the Drupal Menu API
reference (http://drupaldocs.org/api/head/group/menu), wondering how
to easily generate a dynamic tree menu of all _pages_ as well as the
primary menu items. I have familiarized myself with the site taxonomy
menu, and I think I more or less get how this works. But what I would
like to do is to generate a dynamic menu of pages on the site, one
that contains items that go right to a page rather than to a category.
It's a little hard to explain, but all taxonomy items (in the Site
Menu module, or even in the standard Menu system) are links to
*categories*. I'd like to gain direct access to an array of all page content nodes
as well as the top-level navigational items (template menu items) under which they fall.

The Menu documentation *seems* to be mostly geared towards gaining access
to the menu array in order to add items to it. This is very useful
for module developers, b/c it allows them to register their modules
with the menu system.

One way that I am considering to achieve my goal of a non-taxonomic
dynamic menu (god that sounds ugly) is to somehow iterate over each
top-level menu item that PHPTemplate stores (in the variables table, I
believe), and then to compare the Menu alias with the alias for pages
in the installed url_alias table;

I'm wondering if any of you have seen more elegant way of doing
this....and if I somehow missed a pre-existing module for this. Also, can I generate
a taxonomy to mirror the site heirarchy but then generate links directly to the full page
content? It seems that the system is already almost there in this regard, except for the
fact that the links generated in the menus of taxonomy items do not open page content
directy but require a two click process: click on the category, then click on the page link. If
I could use taxonomy_get_tree() to pull the items and then insert an alias to the full page path, that
would also serve my puposes.

The reason I'm interested in this approach is because I'd like to give
users some idea of what kind of pages lie below the top level
navigation (not simply by showing them categories from the
taxonomy) and to give them the opportunity to zip right to the
resource. Gaining direct access to the menu array would also allow me (theoretically)
to insert my own css stuff (ex <li id="current">). It would also be easy
to generate cascading menus based on knowing what pages fall below.

My sincere thanks to whoever is willing and able to help. Please let me know if I need to clarify anything, thanks!!

Comments

nevets’s picture

While it is straight forward to list all nodes, I am unsure what you mean by "The reason I'm interested in this approach is because I'd like to give
users some idea of what kind of pages lie below the top level
navigation". Other that book pages, most content is non hierarchal unless it implied by taxonomy or some other module that allows relationships to be defined. So when you say a "pages lines below the top level" how would you define this?

cfennell’s picture

Hi nevets, thanks much for your response....see below.

Yes, I sort of figured this was the case: hierarchies are defined only by taxonomies. I'm sure this is extremely flexible, perhaps more so than a traditional file structure approach where the hierarchy is implied via the url like:

www.toplevel.com/nextlevel/nextlevel/etc

What I would like is....each time I create a page node, it is "assigned" to a place in the hierarchy of the site so that I can create a dynamically generated menu. By using an alias on each page node post, I can now determine where items will appear under the main menu, all I have to do is assign the main menu item's alias to the post. When I click on the given menu item, I am now directed to the page. I would like to do this with all pages in the site, including those that would fall logically deeper than the main menu item...alias would be menu_item/page/page (this part works fine under the current structure). Then, I would like to make a menu that reflects this organization.

The taxonomy menu comes close to allowing this, but the current system does not seem to allow me to easily link directly to a page (ex www.mysite.com/somepage/) but queries all nodes that have the given taxonomy item. As for seeing "what lies below," the top-level nav might be something like this: http://www.libraries.iub.edu/index.php?pageId=37. The drop-downs contain pages that fall below the top-level items in the taxonomy. This is very powerful for navigation usability. Do you think I could do something like this with the Taxonomy modules?

Thanks for your time!!

nevets’s picture

Have you checked out the menu on the fly module (menu_otf)?
I think this may do what you want.

cfennell’s picture

The Menu on the Fly comes close by making it easier to code posts into the Taxonomy, but it does not allow me to generate (or gain progromatic access) to a true site menu. The problem, it seems, is that Taxonomy items are associated with nodes in a many to many relationship by default. So, when I "tag" a page with a taxonomy item, Drupal assumes that there might be other pages that will be associated with this taxonomy item. As a result, modules that do stuff with site vocabularies generate lists of items that run queries on the node db to see all nodes associated with that particular item. This is extremely useful to pull out content and is really very simple to the way that many blogs work, except that here the categories are hierarchical. But I would like the ability to generate a menu that contains items that link directly to one page per item....this is what I would consider a true site menu. The Menu OTF is really just an advanced site cateogory browser, which is a wonderful thing in and of itself.

The thread that ramdak5000 posted (below) really speaks to my issue far better than I have articulated it here.

http://drupal.org/node/23730

cfennell’s picture

And of course, I suppose I could always hard code my top level menus in the template to get this effect, which might be a lot easier than creating a new module....

venkat-rk’s picture

I am not programmer enough to understand everything you have spelt out. However, I have an intuitive feeling that what you want to build could be very powerful, especially if it could be tied to the proposal by Jeremy Epstein to merge the book and taxonomy modules of Drupal to address their deficiencies.

Kindly read this thread to see if your ideas find a fit somewhere. If not, it would just mean that I was wrong in understanding what you described;-)
http://drupal.org/node/23730

tvst’s picture

i do something similar on my site. my version is pretty customized though, so i can't just give you the code (it wouldn't work).

but all i did was make a module based on the tracker module. you can always start there.

actually tracker.module may be very close to what you want, so you should check that out anyway. (here's what the tracker looks like for drupal.org)

cfennell’s picture

Cool site, I like the way you highlight, then fade out your menu tree. That's a rather interesting usability technique, reminds me of Basecamp's posting system.