Hi everybody,
I am having a seemingly simply problem yet do not know how to solve it properly: Into a certain node's body text I need to insert a link to another node (to node 1234, say). This latter node (node 1234) is in English but it has several translations (node 1235 = French, etc.). What I want is to insert a HTML link into the original node that points to the translation of node 1234 that is in the current locale. So if the visitor is viewing the original node in French and clicks on the link, she'll be directed to node 1235; if the visitor is viewing the original node in English, she'd be directed to 1234.
What do I have to enter in the href of the HTML link in order to get this behaviour?
Many thanks for a hint!
Kaspar
Comments
Comment #1
stmh commentedHere's a small module which will solve your problem (I had it too) Perhaps it can be integrated with localizer.
1) paste this code into a file called localizer-link.info
2.) paste this code into a file named localizer-link.module
3.) create a folder in your modules-directory called localizer_link
4.) copy the two created files there
5.) got to admin/build/modules and enable the localizer link module
To insert links into your posts use "/localized/node/1234" instead of "/node/1234"
if node 1234 has a translation for the current chosen locale, then you'll be redirected to the translated node instead.
Note: this works also for path-aliases, say:
node 1234 has an alias "mysuperalias"
then localized/mysuperalias will jump to the translated node.
Another note: this works vice-versa, say node 1235 is a translation of node 1234 then localized/1235 will jump to 1234 if needed.
Hope that helps,
Stephan
Comment #2
Roberto Gerola commentedYes, this is a very good idea.
I have only to decide if putting these features under localizernode sub module
or under localizer main module.
It will be added, in every case.
Many thanks.
Comment #3
hbfkf commentedDear Stephan,
Thanks a lot for your (sub)module. Very nice: Using it, I can link to a "localized" page by using "/localized/node/1234" or, if I need it, directly to a specific translation, using "node/1234" – great!
As to the question whether this should be a submodule or be part of localizer, I vote for inclusion in localizer. It seems to be such "basic need" when you do localization.
Thanks a lot for sharing!
Kaspar
Comment #4
svihel commentedDont work for me :(
Followed your procedure as you described and it doesnt work. It show error404.
I use normal linking
<a href="/localized/node/124">asdf</a>is it ok, or I missed something about linking in drupal?Comment #5
Roberto Gerola commentedIt should be :
asdf
Note the href : remove the first slash.
Comment #6
napher commentedHas this been added to localizer yet?
Comment #7
napher commentedDoes this work with clean urls off?
Cheers,
Keven
Comment #8
stmh commentedI just tested my script with clean urls set to off and it works just fine.
Note the "?q="
cheers,
Stephan