Is there a way that I could create a custom block that would display an RSS feed as well as other content?

Comments

Lineman-at-lineman.net’s picture

If anyone is interested, here's the solution I found.

$result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY timestamp DESC ", /* feed number here */ 1, 0, variable_get("aggregator_block_limit", 15));

$items = array();
while ($item = db_fetch_object($result)) {
  $items[] = theme("aggregator_block_item", $item);
}

return theme("item_list", $items);
bethhauck’s picture

It's been a while since 2004. Anyone know if you can do something like this in Drupal 6? Can't quite get it to work as is, but maybe I'm not using the right syntax to call the specific feed.

trebuchet77’s picture

I'm bringing in 3 feeds, but Aggregator loses the date, so I am just putting this in a table and themeing via css. I didn't need to grab all the aggregator vars so I'm just using a few here. I'm not a great coder, but this works so I'm a happy coder:

$headerArr = array("","My 3rd title","My 2nd title","My 1st title");	// some titles
$itemArr = array(0,3,3,5);	// getting 5 items from 1st feed, 3 items from 2nd and 3rd
$results = "<table>";			// initilize
for ($i=3;$i>=1;$i--) {		// fid's are just 1,2,3. If needed select group, could just put in numArr and iterate thru that
	$result = db_query_range("SELECT * FROM aggregator_feed af INNER JOIN aggregator_item ai ON af.fid=ai.fid WHERE af.fid = %d ORDER BY  ai.timestamp DESC ", $i, 1, 0, 	variable_get("aggregator_block_limit", 15));
	$results .= "<thead><tr><th>".$headerArr[$i]."</th></tr></thead>";
	$counter = 0;
	while ($item = db_fetch_object($result)) {
		$counter++;
		if ($counter<=$itemArr[$i]) {
			$feed_url = $item->url;
			$feed_title = $item->title;
			$source_date = date("n/j/Y",$item->timestamp);
			$results .= "<tr><td><strong>";
			$results .= "<a href=\"".$feed_url."\">".$feed_title."</a></strong>, ".$source_date;
			$results .= "</td></tr>";
		}
	}
}
$results .= "</table>";
print $results;