views:

56

answers:

1

I have a custom structure for browsing content built with hook_menu and Views. I would like links to content to be routed by node type to the appropriate destination in my structure. So while normally clicking on a node link takes you to node/123, I instead would like to be sent to foo/123 (because node 123 is of type 'foo').

I tried PathAuto but it doesn't work to just make foo/123 an alias of node/123. Specific structure, tabs, etc... has been built using hook_menu for foo/123. PathAuto (as I understand it) is really just displaying node/123 which is just stock drupal node display, and not what I want to be shown.

I started putting together hook_nodeapi and drupal_goto to redirect based on node type. [Working out some infinite redirect issues, but I'm sure I can figure it out.] But do I really want to do this? Won't there be a speed hit to have every link on the site pass through an HTTP redirect?

What's the best way to do this?

Edit
Actually I think the problem is that PathAuto isn't respecting my hook_menu, and possibly not the right tool for the job. With no PathAuto set up yet, I have a hook_menu that defines a page for foo/123 where foo is the node type. Navigating to foo/### works as expected displaying my custom version of node ###.

Now I want to redirect node/### to foo/###, or put another way, I want all links to node/### to be written as foo/###. This seems like an obvious task for PathAuto where under the node type Foo my pattern is foo/[nid]. Except after setting it up, my hook_node no longer functions. That's because now foo/### is being routed to node/### like I asked it to and what's displayed is the vanilla drupal node display, not my hook_menu.

+1  A: 

Actually PathAuto can be setup to specify your kind of custom path. It uses token module to allow you easily reconfigure how pathAuto should build the aliases...

Check in the administration page of pathauto (admin/build/path/pathauto).

Edit

For your edit What I would do is to implements the hook_menu_alter, and I would modify the node/% page callback to your callback used in hook_menu to render the foo/123 page.

Bladedu
hmmm, I've given PathAuto a go but I think my problem is more complicated than that. Updated the question.
AK