It would be good to provide the playlist view type as an argument as well as a view style type -- the same way Views has RSS as both a view type and an argument.

This would allow you to look at a view of nodes, and then also append /playlist to that view's URL to get the playlist.
I've been looking at how Views does this and it doesn't look too complex to implement -- can pretty much copy how views_rss.module does it.

Comments

joachim’s picture

Status: Active » Needs review

Add the following function to the XSPF module:

/**
 * Implementation of hook_views_feed_argument
 * When a view has the 'Node: Feed Selector' argument present, 
 * an value of 'playlist' in this argument will produce an XSPF playlist
 */
function xspf_playlist_views_feed_argument($op, &$view, $arg, $argdata = NULL) { 
  if ($op == 'argument' && $arg == 'playlist') {
    $view->page_type = 'xspf_playlist';

    if ($argdata['options']) {
      $view->description = $argdata['options'];
    }

    // reset the 'real url' to the URL without the feed argument.
    $view_args = array();
    $max = count($view->args);
    foreach ($view->args as $id => $view_arg) {
      ++$count;
      if ($view_arg == $arg && $view->argument[$id]['id'] == $argdata['id']) {
        if ($count != $max) {
          $view_args[] = $argdata['wildcard'];
        }
      }
      else {
        $view_args[] = $view_arg;
      }
    }
    $view->feed_url = views_get_url($view, $view_args);
  }
}

You can then have a regular view of nodes, teasers, tables, etc, and if the 'Node: Feed Selector' argument is present, 'playlist' gives you the XSPF.

arthurf’s picture

Great idea. I will roll this into the next release. It might also make sense to switch around xspf/node/NID to node/NID/xspf so that this is consistent. We might also want to consider switching "playlist" to "xspf" in your example so it is more specific- playlist could mean many things I think.

arthurf’s picture

Ok, I tweaked this around a bit, used "xspf" as the argument, and added the views_post_view() function which was necessary to get this to work, however, it is running on my dev site, so it should be worth testing at this point. Again thanks for the patch. It is great to get some help!

joachim’s picture

views_post_view()? I've not added that to my version of this module and it works fine...

Having 'xspf' as the argument value, is clearer, yeah :)