0

My content type has a Link field which stores a website URL (e.g. 'site.com'). I use this field in various views and node templates.

My site is multi-language, and I know how to check the current language using the global $language.

Now I need to modify the link field value depending on the selected language. So output 'site-en.com' if visitor is viewing the site in English, 'site-de.com' if viewing in German etc.

I can't use manual field translation (Entity Translation) because the field values are imported from XML using Feeds, and there are hundreds of values.

So I wonder if there is a hook to programatically modify a field value before it is used by templates and Views module?

Or maybe there is a better way..?

1
  • Have you tried using hook_preprocess function in your template.php file? Jun 28, 2012 at 20:14

1 Answer 1

0

copy /modules/field/theme/field.tpl.php to your theme folder and rename it to field--field-site-link.tpl.php (if field key of your field is field_site_link), edit template, see comment in file for avalable variables, or just override existings

1
  • I followed this - thanks. In the end I made a small module with a function that checks the current site language and does a rewrite if required. Then I pass the content of the field to this function in field--field-site-link.tpl.php
    – pushka
    Jul 7, 2012 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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