Is it possible to specify a view with arguments? If so, how?

Comments

Scheepers de Bruin’s picture

Not out of the box. You can fake it, however:

  [popup php='$view = views_get_view('my_view'); return $view->preview('my_display', $args)';]

where $args is a keyed array containing your arguments.

MadOverlord’s picture

Thanks for the quick reply. But might I suggest that you consider adding such functionality? It would permit a lot of interesting things without the mess and security issues that come along with PHP.

pimousse98’s picture

Hi, I am trying a combination of what is described in this post and this: http://drupal.org/node/606956
-- in essence I have a table view with views_customfield and am trying to show a link to comments that shows a view of the most recent comments for the node as a popup.
The view is called "publication_comment" and takes NID of the node as an argument. One of the displays is a page -- assuming I have to use "page_1" which is its identifier.

I end up with code somewhat like:

<?php print popup_filter_process_text('[popup php="$view = views_get_view(\'publication_comment\'); return $view->preview(\'page_1\', $data->nid);" title="A test"]'); ?>

I get the following error, which sounds like basic php: Parse error: syntax error, unexpected $end in ....popup_filter.module(322) : eval()'d code on line 1 - any input?
Since customfields allow full php, is there a more graceful way to do that?
Thanks

Scheepers de Bruin’s picture

Until I get a chance to add view arguments to the popup markup as MadOverlord suggested, write a php function to wrap all that, and then you may call the function from within the php argument...

Scheepers de Bruin’s picture

Assigned: Unassigned » Scheepers de Bruin
Status: Active » Closed (fixed)

Yup, it is in v3, thanks for thew suggestion!