Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In future versions of this module, would it be conceivable to store the redirect page in the variables table instead? This would make redirecting to language specific pages possible.
Comments
Comment #1
frankcarey CreditAttribution: frankcarey commentedHow did I store it? By adding a field to the contact table?
You may want to have a different redirect per page, so how about storing a default redirect that can be set?
what is the limit (roadblock) to translation as it is now?
Comment #2
d.sibaud CreditAttribution: d.sibaud commented+1
Comment #3
jmlavarenne CreditAttribution: jmlavarenne commentedIf you store it with variable_get() and variable_set(), with a variable for each page, instead of in the contact table, we can add those variables as multilingual variables in the settings file, and a separate variable will be stored in the variables table for each language. See this : http://drupal.org/node/313272
You wouldn't need an .install file with the module anymore.
db_query() in contact_redirect_contact_admin_edit_submit() and contact_redirect_get() would need to be modified to do variable_get().
At this point I would not know how to preform translation on the redirection. I used a trick - the destination pages have the same path but because the language prefix gets added before the path alias, a different page can be reached for each language.
Comment #4
frankcarey CreditAttribution: frankcarey commentedTrying to get this feature in core.
http://drupal.org/node/306662
One option put forth is use of d6 triggers instead. Would that work for the multi-lingual folks moving forward?
In general, doesn't one of the new translation modules handle this better now where folks are redirected to translated content if it exists?
Comment #5
jmlavarenne CreditAttribution: jmlavarenne commentedI don't think it will work as suggested. I replied in the thread here :
http://drupal.org/node/306662#comment-1389966
I don't have any experience with triggers and actions yet, so I can't make suggestions on that matter.
If you don't want to use the variables table but would like to provide multilingual support, my other suggestion is that your module could have it's own table instead of adding a field to the contact table, with cid, language, and redirect fields.
It seems more complicated than using the variables table because i18n module takes care of translating variables.
Your module could query this table with a method similar to this :
It would require lots of changes elsewhere too, maybe with redirect fields for each language, one for each item returned by language_list().
Comment #6
frankcarey CreditAttribution: frankcarey commentedI would be more keen to having a separate table instead of a variable for every contact form than a separate variable for every contact form. I would certainly want to make it easy as possible for users to have content be translatable, but I'm not sure we want to do something kind of weird to fill this limited use case, where you would want multiple redirect destinations based on language. Having a separate table would mean that this remains a contrib module. My ears are still open though.
Comment #7
jmlavarenne CreditAttribution: jmlavarenne commentedSure - if you build your module to use it's own table, and said table includes a field for language, I can help with the language detection process.
I recommend making these changes available only with the 6.x version, because language support is somewhat different in core with 5.x. I've used the 6.x patch in the other issue and it works well.
Comment #8
frankcarey CreditAttribution: frankcarey commentedIs there a way to handle language specific stuff outside of this module? I don't mind creating hooks and the like, but i think a specific implementation would be out of scope for this module. I understand that system variables instead of storing values in the table directly would allow for this, but I've expressed my reservations about that method above. Any other ideas?
I'm moving forward with the 6.1.x patch that was submitted quite a while ago that uses the existing model instead of one of the proposed methods. A solution would then be in a 6.2.x version. Again, this module should work for multiple languages, but i just want us to make a good decision on how do do that.
Comment #9
frankcarey CreditAttribution: frankcarey commentedchanging title to better represent general issue.
Comment #10
frankcarey CreditAttribution: frankcarey commentedDoes the active translation module solve some issues?
http://drupal.org/project/active_translation
it looks like it would handle missing translations by providing untranslated content as a backup.
Comment #11
jmlavarenne CreditAttribution: jmlavarenne commentedI don't think another module is needed if we find a way that is simple to implement and maintain using the core API.
What about calling translation_path_get_translations() on the path you retrieve from your query, then selecting the appropriate path from the array according to the user selected language, as defined by $language?
That way your module does not need to store the other language path, just the default language. Core provides the translation path.
Comment #12
frankcarey CreditAttribution: frankcarey commentedI'll take a look at this function. Do you know of a contrib module that uses it?
It just seems like this should be abstracted out better, probably in core or with another module to handle the path translation. What I would expect is for this module to store 1 path only, and that some other module would intercept the redirect to change it on it's own based on language. This would mean that if I am in spanish and I go to /mypage that I would be immediately redirected to /myspanishpage instead. I think another module does this no? If it doesn't should that be written for this general use case of translating paths on the fly?
Comment #13
jmlavarenne CreditAttribution: jmlavarenne commentedThat would be great - store one path, and when your module retrieves it, use translation_path_get_translations() to get the paths for all translations to that content, then determine which one to use by looking at the current user's language in the $language variable.
Comment #14
frankcarey CreditAttribution: frankcarey commentedseems like some other module should exist to do the second part. (use translation_path_get_translations() to get the paths for all translations to that content, then determine which one to use by looking at the current user's language in the $language variable)
What i would like to do is just hook into that module, let it's logic make the decisions as to where if any loaction to change the redirect to, and then just shove whatever it gives me into the #redirect field.
This is what I have in mind
Comment #15
jmlavarenne CreditAttribution: jmlavarenne commentedI don't know if there is such a module - but here's what I think you could do without too much more code. No other module required but core modules.
---------------------------------------------------------------------------------------
This is how I tested the functions in a template file to figure out exactly what is needed for this module
The output will be something like this :