Hi,

I'm trying to construct a simple if statement in a code field like this:

if ($entity->field_height['und'][0]['value'] != "") {
  print t('Height') . ': <strong>[node:field_height] mm</strong>'; 
}

It is working ok and sentence is printed if height is defined. But if there's no height value it throws me an error:
Notice: Undefined index: und in eval() (line 7 of /var/aegir/platforms/drupal-7.12/sites/all/modules/ds/ds.module(954) : eval()'d code).

I have a multilingual site. What might be the problem here...?

Regards, Mary

Drupal 7.12
PHP 5.3.3-7+squeeze3
PHP memory limit 128M
PHP register globals Disabled
Database system MySQL
Database system version 5.1.49-3

Comments

swentel’s picture

Status: Active » Closed (works as designed)

That's a PHP error, not an error with DS. You need to check if field_height actually exists or not.

ladyofthelake’s picture

Of course! This works:

if (!empty($entity->field_height)) {
  print t('Height') . ': <strong>[node:field_height] mm</strong>'; 
}

Thanks!