Is there a way to display the listed nodes' teasers, not just the titles?
TIA.

Comments

jjeff’s picture

You could do this by overriding the theme function for theme_similarterms()

It normally looks like this:

/**
 * Theme function for similar block
 * note that $nodes is a list of node parts from the 'node' data
 * these are not complete node_load() objects
 *
 * @param array $nodes
 */
function theme_similarterms($nodes) {
  if (!empty($nodes)) {
    $output .= "<ul>\n";
    foreach ($nodes as $node) {
      $output .= '<li>'. l($node->title, 'node/'. $node->nid) ."</li>\n";
    }
    $output .= "</ul>\n";
  }
  return $output;
}

but you could alter it to do something like this:

/**
 * Theme function for similar block
 * note that $nodes is a list of node parts from the 'node' data
 * these are not complete node_load() objects
 *
 * @param array $nodes
 */
function phptemplate_similarterms($nodes) {
  if (!empty($nodes)) {
    $output .= "<ul>\n";
    foreach ($nodes as $node) {
      $fullnode = node_view(node_load($node->nid), TRUE); // <-- added
                          // (note: full node load/view might be inefficient)
      $output .= '<li>'. l($node->title, 'node/'. $node->nid) ."
      <br />". $node->teaser // <-- here's the teaser
      ."</li>\n";
    }
    $output .= "</ul>\n";
  }
  return $output;
}

disclaimer: the above code is COMPLETELY UNTESTED

rramlani’s picture

Hi, I am also interested in displaying the node teaser( node url with a thumbnail image if possible ) instead of just the node url. Do I need to just copy the above function to themes/my theme/template.php or is there anything else I need to do?
Thanks

kylejaster’s picture

Component: Documentation » Code
Category: support » feature

The code above does not work, I believe this is because '$nodes' is not an actual node_load object, but is "a list of node parts from the 'node' data" (copied from comments in similarterms.module). Would it be possible to return full node-load objects? I do not have the chops to make this work, but am very interested in getting all node data from the module.

Thanks

d0t101101’s picture

I'm also seriously interested in this feature.
.

encho’s picture

Trying to have this as well. Subscribing.

rmiddle’s picture

Theme now get passed a full node instead of just a few fields. Done in CVS will be included in Release x.x-1.2

Thanks
Robert

rmiddle’s picture

Ok I added the abilty to display teaser in CVS will be included in 1.7.

thanks
Robert

rmiddle’s picture

Status: Active » Fixed
rmiddle’s picture

Status: Fixed » Closed (fixed)