In some cases, a Chado record may have a corresponding Drupal page (or node) and we would like to provide a link to that page. For example, for features, there is always a corresponding organism page. By default, Tripal will automatically expand FK relationships defined by the base table. Thus, within a feature object, the organism record is automatically available. If the object has a Drupal node, then the nid will be automatically added. The code below shows how to obtain the node ID of the organism:
$nid = $feature->organism_id->nid
Even though the nid field is not part of the organism table, it is always available in the record if a Drupal node exists. In FK relationships defined by other tables, however, the node information may not be automatically populated. This information can be obtained by expanding the record as done previously. For example:
$feature = tripal_core_expand_chado_vars($feature, 'node', 'organism');
Notice the second argument is node and the third argument is the Chado table. Using this code, the node information will be added if it is not already there.