I'd love to have a view with one argument to specify filtering. Yes, views can already do that, super! But, for the default argument, I'd love to see an additional option (rather than just the display all values, return 404, etc) which would allow you to display another page. This would allow me to have an "index page" for my view which has arbitrary data.

Make sense?

cheers,
-o

Comments

merlinofchaos’s picture

That's a very interesting idea. I'm not entirely sure how I would implement it, but I understand the kind of thing you mean. I assume the 'summary' mode is not the kind of index you want to show?

You could code something up pretty quickly which does what you want:

function custom_page($arg = NULL) {
  if ($arg) {
    $view = views_get_view('viewname');
    return views_build_view('page', $view, array($arg), $view->use_pager, $view->nodes_per_page);
  }
  else {
    ... return output for your index...
  }

}

May not be ideal but it's an effective workaround and isn't too difficult to code.

oliver soell’s picture

Awesome, that should work nicely. I'd still find it a nice feature to have in the gui rather than NOT exporting a page view and using that custom code, but I'm not too afraid to get my hands dirty too :)
-o

marcoBauli’s picture

Caution: php-n00b question!

so this means a view that would normally display no results (arguments), could display a custom node instead?

if i am on the right path, could you please throw some more light for the blind ones on that ... return output for your index...: what would the code be to show for example 'node/444'? and also where is supposed to be inserted, in the argument handling code or in the module itself?

thank you!

oliver soell’s picture

something as simple as this may work for ya:

return node_view(node_load(444));

But this whole code block would be on a custom page - make sure the input format is php - or yes, in a module. When you create your view, don't have it export a page, since that's what we're doing here.

I'm no ninja, no guarantees that this will work :)
-o

merlinofchaos’s picture

Status: Active » Fixed

This patch lets you put whatever you like in the empty text (you can probably do something like check $GLOBALS['current_view']->args to see if it's because there were no results or because there was no argument) and hopefully that will cover your needs.

Anonymous’s picture

Status: Fixed » Closed (fixed)