Ok guys, I have a website with a lot of custom made modules and theme. I need to upgrade the site from D6 to D7.

The theme and modules make heavy use of the convention $node->field_my_custom_field[0]['value'] to access CCK values. I know in D7, you need to add an additional ['und']..... I have some questions:

  1. Is there a way to remove the need of the ['und'] ? or it's impossible and not recommended? So I need to rewrite all the modules and theme?
  2. Are the values equivalent in D6 and D7?
    ex.
    $node->field_my_custom_field[0]['value'] same as $node->field_my_custom_field['und'][0]['value']
    $node->field_my_custom_field[0]['view'] same as $node->field_my_custom_field['und'][0]['view']

    etc...

Comments

VM’s picture

This question is better served in the 'module development and code questions' forum. Please edit the opening post and move it. Thanks.

Jaypan’s picture

Is there a way to remove the need of the ['und']?

Not that I know of, but even if there were, I wouldn't recommend it, as it's a major part of core and you will run into problems all over the place, particularly with any contributed modules that are expecting it.

So I need to rewrite all the modules and theme?

Unfortunately, yes.

Are the values equivalent in D6 and D7?
ex.
$node->field_my_custom_field[0]['value'] same as $node->field_my_custom_field['und'][0]['value']
$node->field_my_custom_field[0]['view'] same as $node->field_my_custom_field['und'][0]['view']

Yes.

One note, you should never actually use 'und' in your code, you use LANGUAGE_NONE (no quotes). Ex:

$node->field_my_custom_field[LANGUAGE_NONE][0]['view']
gunjack07’s picture

thx man! Maybe I should use entity API instead? It manages the language automatically right?

dipali.goel25’s picture

Hello

Und can be replaced by LANGUAGE_NONE

We can write

$node->field_custom_field[LANGUAGE_NONE][0]['title']

language none replaces along with the all translation automatically