Drupal RelatedContent module: Block with links to related content


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.