hi
i wrote my own teaser-list for my custom modules content-type
because for some reasons i dont want to list the node-teasers by taxonomy terms
i want to list them by content-type
i also dont want to use the views.module
so. it would be a great help for me if you could tell me if the following code is the right thing to generate a list of nodes

<?php
function _blog_teaserlist() {
	$output = '';
// get a paged list of nodes of specific content-type
	$result = pager_query(db_rewrite_sql(
			"SELECT nid FROM {node} WHERE status = 1 AND type = 'blog' ORDER BY sticky DESC, changed DESC"
		),variable_get('blog_teaser_maxdisp', 5));
	 while ($nodeid = db_fetch_object($result)){
		// load node data
		$node = node_load($nodeid->nid);
		// add themed teaser
		$output .= theme('node', $node, true, false);
	 }
	return $output;
}
?>

if this is a valid way to generate a list of nodes in teaser view how can i create a rss feed out of it
i tried node_feed() but it doesent seem to generate valid feed urls
do i have to preprae something beforehand

thanx for any help

Comments

nancydru’s picture

I'd say there are some readability problems, but that's totally up to you.

One thing you might want to do is:

    return $output . theme('pager', NULL, variable_get('blog_teaser_maxdisp', 5));

Sorry, I don't RSS so I can't answer that part.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

kabaman’s picture

thanx for your quick reply
> I'd say there are some readability problems, but that's totally up to you.
you mean my bad english or the code ?
> return $output . theme('pager', NULL, variable_get('blog_teaser_maxdisp', 5));
yes. i forgot to post it because its in another section of my code

best wishes

Barry Pretsell’s picture

I've never done this, but I quick search of the code and I found format_rss_channel, see events and views modules for examples of its usage.

kabaman’s picture

thanx for your reply
i use now node_feed which is calling format_rss_channel
here is my solution which works for me

<?php
function _blog_feed() { 
  $result = db_query_range(db_rewrite_sql("SELECT nid, created FROM {node} WHERE status = 1 AND type = 'blog' ORDER BY sticky DESC, changed DESC"), 0, variable_get('feed_default_items', 10)); 
  $channel['title'] = variable_get('site_name', 'Drupal') .' Blog'; 
  $channel['link'] = url('blog', NULL, NULL, TRUE); 
  $channel['description'] = $term->description; 
  node_feed($result, $channel); 
}
?>
<?php
function blog_menu($may_cache) {
  $items = array();
  if (!$may_cache) {
    $items[] = array(
      'path' => 'blog/feed', 
      'title' => t('Blog RSS Feed'),
      'callback' => '_blog_feed',
      'type' => MENU_CUSTOM_MENU,
      'access' => user_access('access content')
    );
  }

  return $items;
}
?>
kabaman’s picture

forgot to say that i just adapted the original blog_feed_last() function of blog.module

achilles_cheskonov’s picture

thanx kab , i wanted to show a rss feed which will include all the post for a specific taxonomy of blog , your solution did the trick for me . thanx again.