It would be nice if the module could support per-book feeds: all pages in the book could carry the feed, which would list updates within the book (or to child pages below a given page), and only there, so it would be less generic than the overall node feed at rss.xml

CommentFileSizeAuthor
#8 book_feed_d5.patch3.76 KBfgm
#4 book.module_24.patch2.66 KBfgm
#1 book.module_22.patch1.98 KBfgm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fgm’s picture

FileSize
1.98 KB

FWIW, here is a patch rolled against Drupal 5.1. I haven't checked book.module in v6 yet...

It could be both simpler and more efficient if node_feed could take an array of nids in addition to a query. It could accept both by checking the param type: this is something it already does by providing a default query if none is supplied.

That way, book_feed could just build a list of nodes using book_recurse without adding yet another point where an RSS feed is generated.

fgm’s picture

Status: Active » Needs review

Forgot to set status and mention that you can check it in action at http://www.php-gtk.eu/handbooks

cburschka’s picture

I'd like this.

The patch is probably broken by now; I'll test it shortly.

fgm’s picture

FileSize
2.66 KB

Here is a patch rerolled agains today's HEAD.

catch’s picture

Version: 6.x-dev » 7.x-dev

still applies with a lot of offset, won't get into D6 though.

catch’s picture

Status: Needs review » Needs work

drupal_add_css() no longer goes in !may_cache - also this would be quite easy to do in views. Since views may end up in core in D7, I'd rather see this dealt with alongside node_type views and rss feeds.

buzink’s picture

A book feed should be standard functionality, like a group feed, taxonomy feeds, etc.

I reworked the code in the patch above for drupal 6 (see below). There's only one big problem, the book feeds seem to show only one item (the first bookpage from that point in the hierarchy). Anyone?

---

If you want to add feeds per book, do the following.

In book.module, below

     'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
         );
       }

add

      if (user_access('access content')) {
        $links['book_feed'] = array(
          'title' => t('Feed'),
          'href' => 'book/feed/'. $node->nid,
          'attributes' => array('title' => t('Access a feed of all changes below that page in the book hierarchy.'))
        );
      }
     }
   }

(this makes the link to the feed appear)

below

 'access arguments' => array('access printer-friendly version'),
     'type' => MENU_CALLBACK,
      'file' => 'book.pages.inc',
   );

add

  $items['book/feed/%'] = array(
    'page callback' => 'book_feed',
    'page arguments' => array(2),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'file' => 'book.pages.inc',
  );

(this makes the link call the bookfeed-function)

Now add the bookfeed function to the file book.pages.inc:

/**
 * Ancillary PRE function for book_feed
 *
 * @param $node
 *   The node object being traversed
 */
function _book_feed_pre($node) {
  $pubDate = date(DATE_RSS, $node->changed);
  return format_rss_item(
    $node->title,
    url("node/$node->nid", array('absolute' => TRUE)),
    strip_tags($node->teaser),
    array('pubDate' => $pubDate)
    );
  }

/**
 * Ancillary POST function for book_feed
 *
 * @param $node
 *   The node object being traversed
 */
function _book_feed_post($node)
  {
  return NULL ; //"post $node->nid ";
  }

/**
/**
 * Return a feed to nodes below the passed-in node in the book hierarchy,
 * 
 * @param $nid
 *   Node below which the feed is built
 */
function book_feed($nid) {

  global $base_url;

  $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
  $node = node_load($nid);
  $tree = book_menu_subtree_data($node->book);
  $items = book_export_traverse($tree, '_book_feed_pre', '_book_feed_post');
 
  $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
    . "<rss version=\"2.0\" xml:base=\"$base_url\" ". implode(' ', $namespaces) .">\n"
    . format_rss_channel($node->title, url("node/$nid"), $node->teaser, $items)
    . "</rss>\n";
  drupal_set_header('Content-Type: application/rssxml; charset=utf-8');
  print $output;
}
fgm’s picture

FileSize
3.76 KB

FWIW, since this was a D5 issue initially, here is the patch rerolled (and fixed !) for DRUPAL-5--21.

Not setting for review to prevent PIFR from testing it against D7.