Generating an alias for all tabs on a node

melban's picture

I'm currently implementing multiple tabs on different types of content nodes. It really bugs me to keep the tab links as node/%/tabname instead of using alias/%/tabname. I've not been able to find a solution to this and my attempts to create a module or addition to Pathauto have also come to necessity.

I'd like to do this with the lease amount of future maintenance as possible by using wildcards but the only idea I've got is to create some type of automatic generation of alias record for each node/tab combination that exists. This could be easy but if I decide to add tabs in the future I'd have to go back and regenerate aliases for all missing items.

Node path: 'league/5'
Tab path: 'node/5/games'
Wanted: 'league/5/games'

All suggestions are greatly appreciated.

Groups:
Login to post comments

I've been bugged by this

earnie's picture
earnie - Mon, 2009-04-20 13:32

I've been bugged by this since I started using the path module. I think it should be resolved there instead of a new module to augment the suite. But implementing as a module might be tough since there is no hook_url. I would like to see this implemented without creating a url_alias for every possible menu. There is a hook_menu_link_alter and/or hook_menu_alter that might work to facilitate this. I'm not sure if you could use the url() function to get 'league'5' from 'node/5' or not, if so then using url() with a shortened path until there is a difference or nothing left might work. If not then browsing through the url_alias table for a src from the shortened path would be the next option.

Good luck, I'm looking forward to seeing this in action.


Without alias it doesn't work

melban's picture
melban - Mon, 2009-04-20 13:58

I was playing around with this a little more last night and even if I put path 'league/5/games' as the URL I get access denied because it is not setup as an alias so it isn't just a url() issue. I'm going to have to dig deep into path and see what type of patch I'd have to even apply to get this to work.


custom_url_rewrite_inbound/outbound for D6

markus_petrux's picture
markus_petrux - Mon, 2009-04-20 14:00

custom_url_rewrite_inbound() is invoked from drupal_get_normal_path(), when $_GET['q'] is normalized on bootstrap. And custom_url_rewrite_outbound() is invoked from url(). These pair of functions allow you to implement path aliases programmatically.


Specialty functions aren't copacetic.

earnie's picture
earnie - Mon, 2009-04-20 17:47

This is just stupid. Why are these two not a hook already. They are a custom function that if it exists gets called by drupal_get_normal_path or url. I say it's stupid because some module implements the function and then some other module implements the same function you then have a conflict of interest. All such functions need to become hooks, IMO. The drupal_mail_wrapper one has bit me more than once.


These are for custom dev, not module dev

markus_petrux's picture
markus_petrux - Mon, 2009-04-20 17:58

Still, a module could make use of them, but IMO, these functions are provided to allow sites implement custom paths. There should be no data access in these functions, specially on the outbound version, that might be invoked hundreds of times per page. It's just a place to code logic to resolve particular needs.


Outclassed

melban's picture
melban - Tue, 2009-04-21 04:12

After digging and digging I think I'm way out of my league when it comes to understanding how this works and won't be able to create a solution. I'll keep trying but am very doubtful.


existing work in d7

greggles's picture
greggles - Tue, 2009-04-21 15:11

It's not missing for lack of desire ;)

That said, there is a patch to add this feature for Drupal 7: http://drupal.org/node/40696

Perhaps that could get committed and then we could see about somehow backporting it?

--
Growing Venture Solutions | Drupal Dashboard | Learn more about Drupal - buy a Drupal Book


Too Cool

melban's picture
melban - Sat, 2009-04-25 23:34

Thanks for giving me that link it will be cool to see the functionality in 7x.

I think I figured out what I was doing wrong. I should have been creating my own module for content type instead of using creating one using the delivered create content-type functionality. This will allow me to manage the URLs and do many more things I was frustrated with not being able to do. Thx to everyone for thinking about this issue.