views:

136

answers:

3

Hi, I need to write a module that gives me a page will all possible paths in a drupal install, including orphaned pages. (site map won't work for that).

I can query the url_alias table for aliases, and I can query the menu_router table for all paths, even ones set in page/feed displays in views. But, variable paths (those with arguments) get interpreted at run-time.

So, is there a way to get all possible paths in a drupal install, including dynamic paths and orphans? It's catch22. I have to know all the urls ahead of time to get them.

A: 

All possible paths in Drupal itself? menu_links table should have all of that listed as registered paths in the system.

Kevin
That won't give you wildcarded URLs though. It'll be something like 'node/%node/edit' instead of all the various edit pages.
ceejayoz
Aren't those in menu_router too?
Kevin
A: 

You may want to check out the menu_edit_validate() function to see how drupal checks if the link for a new menu item has a valid path.

I don't think it's possible to get a list of all possible paths including the ones with variable values in it. The essence of such a dynamic path is that is can accept multiple values. Of course you could loop through the menu items and, when you come across node/%node/edit, add a new item to your list for every node ID in your database. However I don't see how that could be useful for anything....

Can you explain which problem you're trying to solve? Maybe we can help you find an even better solution.

marcvangend
We have our own middle-ware to render and serve content but we use Drupal to manage the content. Then we use custom feeds to transform views into XML. We also need to cache the feeds to static files which our middleware can access. These feeds are "orphans" so I can't use wget to crawl the site and cache them. What I did is write a script to merge the urls from url_aliases and menu_router tables. In this case I know that the '%' signs are tax terms, I can query the db and substitute the terms in. Then I write those paths to a file. I can then use wget on that file to generate the static files.
Aaron
My solution above is hacky; I'd rather have something general enough so that I don't have to know anything about what the url arguments are. Is there no hook that I can use when that variable gets interpreted?
Aaron
+2  A: 

So, you can definitely get all possible paths in drupal by querying the url_alias table (that gives you all aliases), and menu_router, which will in addition give you paths set by page or feed displays. The problem remains that you cannot fill in the variables in variable paths in the menu_router table. You have to know in each case what the variables could be, since Drupal fills them in at runtime.

So my problem is a catch22. You have to somehow visit all the paths to get them, but you can't programatically visit them (or crawl them) unless you know what they are in advance.

Aaron