Index: relatedlinks.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/relatedlinks/relatedlinks.module,v retrieving revision 1.41 diff -u -F^f -r1.41 relatedlinks.module --- relatedlinks.module 8 Nov 2006 22:01:59 -0000 1.41 +++ relatedlinks.module 13 Nov 2006 17:11:44 -0000 @@ -115,11 +115,17 @@ function relatedlinks_block($op = 'list' $blocks[$type]['info'] = t('Related links: ') . check_plain($config['name']); } } - + + // use block #9 to leave some room for more types + $blocks[9]['info'] = t('Backinks'); return $blocks; case 'view': // This is only valid if we're looking at a node now. if (arg(0) == 'node' && is_numeric(arg(1))) { + if ($delta == 9) { + return relatedlinks_block_backlinks(arg(1)); + } + $block = array(); $node = node_load(arg(1)); // Only display if node type is associated with this module. @@ -167,6 +173,25 @@ function relatedlinks_block($op = 'list' } /** +* Return a block if other nodes are linking to the specified node. +* +* @param $nid +* The node id to which other nodes link +* +* @return $links +* An associative array containing 'subject' and 'content' elements as usual for Drupal blocks + */ +function relatedlinks_block_backlinks($nid) { + $sql = "SELECT n.title, n.nid FROM {relatedlinks} r INNER JOIN {node} n ON r.nid = n.nid WHERE url LIKE '/node/%d' AND n.status = 1"; + $result = db_query($sql, $nid); + if (db_num_rows($result)) { + $block['content'] = node_title_list($result); + $block['subject'] = t('Backlinks'); + return $block; + } +} + +/** * Implementation of hook_nodeapi(). * * @TODO: Move the parsed links filtering into a filter_process(). The current