Posted By

aleprieto on 08/21/08


Tagged

module drupal block


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

basicmagic


Drupal RelatedContent module: Block with links to related content


 / Published in: PHP
 

URL: http://drupal.org/node/218844

This code snippet make use of the API to accomplish a block with links to related content.

  1. <?php
  2. if (arg(0) == 'node' && is_numeric($nid = arg(1))) {
  3. $host_node = node_load($nid);
  4. $grouped = relatedcontent_variable_output_grouped($host_node->type);
  5. if($groups = relatedcontent($host_node, $grouped)) {
  6. foreach($groups as $group => $nodes) {
  7. if ($nodes) {
  8. $links = array();
  9. foreach($nodes as $node) {
  10. $links[] = l($node->title, "node/$node->nid");
  11. }
  12. $title = relatedcontent_group_title($group, $grouped, $host_node->type);
  13. print theme('item_list', $links, $title);
  14. }
  15. }
  16. }
  17. }
  18. ?>

Report this snippet  

You need to login to post a comment.