need help with PHP in Drupal 7

HI,

I m not a programmer and my code is not working below. I’m trying to configure an Hyperlink path based on the Drupal 7 language chosen. Any help is welcome

Let's get Started
<?php $contact = ""; switch ($language){ case "fr": $contact = '/nous-joindre'; break; case "en": $contact = '/Contactus'; break; default: $contact = '/Contactus'; break; echo $contact; } ?>

I’m not a Drupal expert by any means, but is $language being hit? If not the contact variable stays an empty string.

To check your SWITCH, just display the $language variable before going into the switch code.
Make sure you actually have the language value loaded into your $language variable.

I am weak in Drupal, but, if I remember, it has a way of grabbing the language.
Here is how the website says you need to do it:

global $language ;
$lang_name = $language->language ;

And, then you use $lang_name or whatever to run your compares with… Not sure if this helps at alll…

Sponsor our Newsletter | Privacy Policy | Terms of Service