Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By gunjack07 on
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:
- 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?
-
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
=-=
This question is better served in the 'module development and code questions' forum. Please edit the opening post and move it.Thanks.Is there a way to remove the
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.
Unfortunately, yes.
Yes.
One note, you should never actually use 'und' in your code, you use LANGUAGE_NONE (no quotes). Ex:
thx man! Maybe I should use
thx man! Maybe I should use entity API instead? It manages the language automatically right?
Und usage
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