Blogroll based on Weblinks, linking straight to destination
Last modified: March 11, 2009 - 06:32
The alphabetical blogroll is a common staple on many websites. However, because the weblinks.module creates only blocks of recent and most active weblinks -- and because those blocks' items link to the node, and not to the destination -- this custom code in a block (or, if you want, in a node) can produce an alphabetical blogroll from the weblinks nodes on your site.
This snippet uses the "goto" link tracking, so click-throughs are still counted.
<?php
/* This php snippet generates an alphabetical blogroll list
* drawn from weblinks nodes on your site.
* Links connect to destination, not the weblink node.
* Limit is offered as an option.
*/
$nlimit = 100;
$result = db_query(db_rewrite_sql("SELECT n.title, w.lid
FROM {node} n
INNER JOIN {weblinks_node} wn ON n.nid = wn.nid
INNER JOIN {weblinks} w ON wn.lid = w.lid
WHERE n.type = 'weblink'
AND n.status = 1
AND n.moderate = 0
ORDER BY n.title
LIMIT $nlimit"));
$output = '<div class="item-list"><ul>';
while ($node = db_fetch_object($result)) {
$output .= '<li>' . l($node->title, 'weblink/goto/' . $node->lid);
}
$output .= '</ul></div>';
return $output;
?>This snippet has been tested in Drupal 4.6.
