2

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?

2

I didn't find anything there available for clickers. I could suggest the following alternative:

  1. Activate the "Display Suite Format" module
  2. Create Display Suite "Code field" with following content:

    <?php
      return t(locale_language_name($entity->language));
    ?>
    
  3. Don't forget to activate the "Display Suite code" text format for this code field.
  4. Add this code field to your content type's display!

Hope this helps!

1
  • 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
0

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']);
    }
}
3

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.