Hi,

I am trying to upgrade my 4.7 custom module to 5.1.

Based on the instructions in the Handbook I have changed my code under hook_view in order to show my custom fields.

The problem is, that when I use a code as suggested in the Handbook:

    $node->content['my_field'] = array(
      '#value' => theme('mymodule_my_field', $node->additional_field),
      '#weight' => 10,
    );

then nothing is displayed in the node preview. But when I just skip the theme function, like that:

    $node->content['my_field'] = array(
      '#value' => $node->additional_field,
      '#weight' => 10,
    );

then I am able to see my data. The problem is independent of the theme used in the site...

I just don't get it, what I am doing wrong...

Comments

nofear’s picture

Hi milosh,

you probably haven't got a function

theme_mymodule_my_field($additional_field){
  return $additional_field;
}

This is used so that you or other people can easily overwrite the default theme of that field with a mymodule_my_field.tpl.php file... That way they can theme the field without modifying your module code.

So just add that function in your module and it should work. :-)

cheers, pip

http://humanopinion.org

milosh’s picture

Thanks!
:)