5

Is there any way to programmatically change the Base URL, Just as the "locale" module does..
My Website is multi-lingual which has to recognize 3rd argument, after the language identifier. Some custom code will be triggered when base on the third argument.

Have tried to Find a solution for this but the most of the Solutions suggest settings.php approach.

I am looking for a hook that will allow me to alter the third parameter in the URL for custom functionality.

Sample URL: www.example.com/hi/arg3 Above "hi" is the language identifier and "arg3" will be used for custom functionality. Hence a node to be rendered will have url as www.example.com/hi/arg3/node/1

4

You can do that with:

hook_url_outbound_alter

Keep in mind all URLs run through that function so your hook implementation should be as fast as possible.

Example from locale module:

Rewrite outbound URLs with language based prefixes:locale_url_outbound_alter

See also: Language Negotiation API

3
  • Oops I managed to downvote this instead of upvote it for some reason. Sorry 'bout that, I've reversed it. Congrats on getting to 10k by the way :) – Clive Nov 8 '13 at 11:56
  • Thanks for the solution, will try it out and comment once successfully done – Saheel Nov 8 '13 at 17:20
  • Callback from local_url_outbound_alter goes to locale_language_url_rewrite_url – Saheel Nov 13 '13 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.