How to Configure the OPDS Feed

Filter the editions - support multiple apps

The module allows your to filter the editions supplied in the OPDS feed. This is useful if you wish to have multiple apps that share content.

In order to do this, you need to implement the following hooks in your module.

The example below will provide an OPDS feed that only includes editions with keys that match the array provided. Note you can pass any filter payload into the page arguments, and your filter function can do whatever it wants with it.

// Implement a hook for each endpoint you wish to add
function mymodule_menu() {
  $items = array();
  // OPDS feed (Packages) that only includes the edition with the keys edition-bob or edition-tom
  $items['editions_bobtom.xml'] = array(
    'page callback' => 'pugpig_output_opds_external', 
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'page arguments' => array(array('edition-bob','edition-tom')),    
  return $items;

And the filter hook function looks like this:

// Only keep an edition if the key is in the array we passed in
function mymodule_pugpig_filter_edition($edition, $edition_filter) {
  $filter = TRUE;
  if (in_array($edition['tag'], $edition_filter)) $filter =  FALSE;
  return $filter;

Adding links at edition level

In order to have content that is accessible without downloading the edition first, it must be included in the OPDS feed, for example if you wanted to include preview images of your edition to show at an edition selector level.

// Extra categories for the OPDS feed
function mymodule_pugpig_edition_links($edition) {
  $i = 0;
  $field = 'field_preview_image';
  $links = array();
  if (isset($edition->$field)) {
    $imagenode = $edition->$field;
    if (isset($imagenode['und'])) {
      $imagenode = $imagenode['und'];
      foreach($imagenode as $image) {
        $uri = pugpig_get_image_path_from_node($edition, $field, $i);
        $uri = pugpig_url_out(urldecode($uri), array(), $edition->nid, TRUE);
        $uri = (($edition->status) ? variable_get('pugpig_cdn_base', '') : '') . $uri;
        $title = $image['title'];
        $links[] = array(
          'rel' => "",
          'title' => $title, 
          'type' => "image/jpeg", 
          'href' => $uri
  return $links;
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk