Dear developers,

I have created my 1st custom node module but have trouble to display my custom field. The field is well inserted into the Database and can be updated through my custom form. But this field isn't display on the node page (and also in teaser).

After looking at the node_exemple.module in the API, here is how I have adapted my code.
In the DB, my field is called "pmselection" in a table "absence".
Thanks for your help.

function absence_load($node) {
  return db_fetch_object(db_query('SELECT pmselection FROM {absence} WHERE vid = %d',
    $node->vid));
}
function absence_view($node, $teaser = FALSE, $page = FALSE) {
  $node = node_prepare($node, $teaser);
  $node->content['pmselection'] = array(
    '#value' => theme('absence_pmselection', $node),
    '#weight' => 1,
  );
  return $node;
}
function absence_theme() {
  return array(
    'absence_pmselection' => array(
      'arguments' => array('node'),
    ),
  );
}
function theme_absence_pmselection($node) {
  $output = '<div class="selectpm">';
  $output .= t('The PM is for %pmselection.', array('%pmselection' => check_plain($node->pmselection)));
  $output .= '</div>';
  return $output;
}

Comments

After having the same problem again somewhere else in my custom module, I have finally found the solution. Just need to disable and enable the module again !!!

I will add a comment in the related topic in the "Module developer's guide".

Cheers,
Damien
----------------
Keep Open Spirit

- Damien
:: Keep Open Spirit ::

clear cache or install Cache disable module.