I've tried adding a non-NH view into the node, which works fine, paging works and everything. However, if I add an argument of RSS: Feed Selector, when I visit the node with the embedded view, there is an RSS Selector, but it points to /node/x/feed, instead of the view's RSS feed. That feed does nothing.

I've also tried overriding the nodehierarchy_children_list view, and adding RSS feeds in there, but that doesn't work either. I wasn't really expecting it to, but I can't think of anything else to try to get this to work.

I've followed the code thru which adds the RSS feeds to the node. I don't really know how it is working when it creates the node feed, to be honest, but it's not the desired result, as far as I can tell - not for me anyway!

Comments

ronan’s picture

Status: Active » Fixed

This is fixed in HEAD. Actually I fixed the argument handling code in general, so other arguments should work now too.

niklp’s picture

Fixed indeed, what a legend! :)

Any chance you can give a brief rundown of what was wrong and what you did, with some line numbers or something? This could be useful info for someone else I think...

Cheers!

ronan’s picture

It was actually really simple. For developers, the solution is on line 118 of nodehierarchy_views.module and is fairly well documented in code.

Here's the embed function:

function nodehierarchy_views_embed_children( &$node ) {
  if ( $node->nh_children_view && $view = views_get_view( $node->nh_children_view ) ) {
    // make sure the first argument is a node hierarchy parent argument
    $first_arg = $view->argument[0];
    if ( !$first_arg || $first_arg['type'] !== "parent" ) {
      array_unshift( 
          $view->argument, 
          array(
            'type' => 'parent',
            'argdefault' => '1',
            'title' => '',
            'options' => '',
            'wildcard' => '',
            'wildcard_substitution' => '',
          )
        );
    }
    
    // get the arguments to send to the view
    $arguments = explode('/', $_GET['q']);
    // first arg will be 'node', remove it.
    array_shift( $arguments );
    // the next argument is the nid, this we will pass as the parent, 
    // the rest may be added by the view (feed selectors, calendar params etc)
        
    // set the url of the view so that filters and arguments work
    // NB: setting this to just 'node' works since the nid will be added by the
    // argument code in views (first arg is always the nid). This works but may
    // be taking advantage of a non-api side effect and should be treated with
    // caution.
    $view->url = "node";
    
    $node->content['nodehierarchy_children'] = array(
      "#value"    => views_build_view( 'embed', $view, $arguments, $view->use_pager, $view->nodes_per_page ),
      "#weight"   => 10
    );
  }
}
niklp’s picture

All good - not sure, shouldn't you be using arg() to get the GET values rather than accessing GET directly? Security issue maybe?

Also, I saw the node content line there earlier, but I can't see the value in my output as a variable (using Devel) - is it trivial to make this views data available for theming? Then we can move the Views data about as we see fit...

ronan’s picture

All good - not sure, shouldn't you be using arg() to get the GET values rather than accessing GET directly? Security issue maybe?

Nope, arg() does not do any input sanitizing (http://api.drupal.org/api/function/arg/5). In this case it's up to the views module to filter the input. There is also no way to get a list of all the arguments with arg().

Also, I saw the node content line there earlier, but I can't see the value in my output as a variable (using Devel) - is it trivial to make this views data available for theming? Then we can move the Views data about as we see fit...

The embedded view content is in: $node->content['nodehierarchy_children']['#value'] when you go to theme the node.

niklp’s picture

re 1: ok my mistake, and learning material there too! :)

The embedded view content is not visible in the devel module's output of the node load/render - I suspect this is due to the module's weighting? If so, if you could set the module weight lighter than devel that would help - I didn't think this was working but further inspection proved that it is...

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.