I'm trying to figure out how to get the name of the language of the current node in display suite. I find a language option under one of the node categories in the dynamic field content selector, but that outputs the language code, not the name. Do I need to handle this in a preprocess function or is there some way of getting this that I've not managed to find?
I didn't find anything there available for clickers. I could suggest the following alternative:
- Activate the "Display Suite Format" module
Create Display Suite "Code field" with following content:
<?php return t(locale_language_name($entity->language)); ?>
- Don't forget to activate the "Display Suite code" text format for this code field.
- Add this code field to your content type's display!
Hope this helps!
-
That does look better than what I've done. I got tied up doing something else, but shortly I'll try this out. Thanks! – UltraBob May 20 '16 at 23:46
Here's what I've done. I'd love a better answer:
in my templates.php in my theme (the dynamic field I created in display suite is called language):
function MYTHEME_preprocess_field(&$variables) {
if ($fieldname == 'language') {
$item['#markup'] = locale_language_name($item['#markup']);
}
}
-
You can use the $GLOBALS['language']; https://api.drupal.org/api/drupal/developer!globals.php/global/language/7.x
An object containing the information for the active interface language.
– Gianni Di Falco May 19 '16 at 8:29 -
Yeah, I'm not trying to determine the current interface language. I'm trying to determine the language of the node. – UltraBob May 19 '16 at 8:32
-
Ohh sorry, hmm maybe [menu_get_object] (api.drupal.org/api/drupal/includes!menu.inc/function/…) – Gianni Di Falco May 19 '16 at 8:37