Blogroll based on weblinks, to destination and node, for taxonomy term, with paged results
Last modified: March 11, 2009 - 06:28
Blogroll based on Weblinks, linking to destination and node, limited by taxonomy term, with paged results
Sometimes a blogroll is just too long for one page. We had to code up a weblinks snippet for a site with literally thousands of weblinks. So here is a snippet that lists the sites, linking directly to the destination, while also linking to the weblink nodes themselves -- all with the results presented using Drupal's own pager:
<?php
/**
* blogroll from weblinks, plus weblink link
* Tested with Drupal 4.6.x
* Contributed by Laura Scott, www.pingv.com
*/
$taxo_id = 9; // edit to change term category. If an array of terms, enclose them in "" separated by commas
$list_length = 50; // edit to change length of pages
$sql = "SELECT n.title, w.lid, n.nid
FROM {node} n
INNER JOIN {term_node} tn USING(nid)
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
AND tn.tid in ($taxo_id)
ORDER BY n.title ASC ";
$result = pager_query($sql, $list_length);
while ($node = db_fetch_object($result)) {
$output .= '<li>' . l($node->title, 'weblink/goto/' . $node->lid) . " <div class='linkdesc'>[" . l('Describe or comment on this blog', 'node/' . $node->nid) . "]</div></li>";
}
$output .= theme('item_list', $items);
print $output;
print theme ('pager', NULL, $list_length);
?>For an example in action, see BlogHer's blogrolls.
