php - If/then statement on field value in drupal 7 -



php - If/then statement on field value in drupal 7 -

i'm trying write statment looks @ value in boolean field (field_solo) , returns 1 of 2 template files have created in drupal 7.

my field "field_solo" correctly outputting value of 0 or 1 , have cleared cache.

can tell me if doing correctly? right not getting display when statement true.

function motg_preprocess_node(&$vars) { $node = $vars['node']; if($node->field_solo[0]['value'] == 1) { $vars['theme_hook_suggestion'] = 'node__solo'; } else { $vars['theme_hook_suggestion'] = 'node__video'; } }

instead of

if($node->field_solo[0]['value'] == 1)

make it

if($node->field_solo['und'][0]['value'] == 1) // or if($node->field_solo[language_none][0]['value'] == 1)

php drupal if-statement drupal-7 drupal-theming

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -