tags:

views:

49

answers:

3

I have a custom content-type called 'document' On this content-type, I have a File field where a user can upload a document.

Assume the path to a document node is /somesite/document/tester

I would like to be able to link to /somesite/document/tester/file and it automatically go to the file that is uploaded to the file field of the node. I have tried the url_alter module and am able to get the correct url of the document but when it tries to go there, it says not found. It seems that my redirection is still trying to be rewritten with pathauto or something.

Ulitamtely, we want to have a consistent url for these documents so that a user can upload a replacement document and we can still use the same urls. Any ideas?

A: 

I think you can do this with path_redirect.

A scalable solution though, I don't know if there is a module for it.

http://drupal.org/project/path_redirect

Kevin
A: 

You could pretty easily write a module doing that. If you have the node id it's a trivial query required to get the URL for the file. Then you could use drupal_goto to redirect to the file.

It would require some work if you want to get the URL transformed into what you suggest. The problem with a URL like that is that it isn't nessesarily unique. This might give you problem anyways. So would be better of making a unique URL and then hook into path auto to make the alias.

googletorp
A: 

Use file_aliases

Nikit