Hi, a useful feature would be able to enter arguments to be sent when creating the views component.

This would enable the view to restrict by terms, content type etc.
Possible?

Comments

dman’s picture

Actually, yeah. Don't see why not.
Could be an additional parameter on the view component config I guess.
I think we've already got enough control of the view object to give it args at build/render time.
A bit of fiddly work to test it all though...

Roulion’s picture

Subscribe too

this woumld be very useful to filter some huge views (for instance the argument would be a field un the webform node type, so the ability to pass token as argument would be nice (i need to pass 2 arguments)

Roulion’s picture

A possibility to do this without any patch is adding your arguments to the webform node-type (term reference for example). In the view used to display the form, you can parameter the default argument value in php with a custom code such as

// the node url is node/XX where XX is the node id, node = arg(0) and XX = arg(1)
// we assume the view is called only on the webform node. 
if (isset arg(1)) && is_numeric(arg(1)))
{
$data = node_load(arg(1));
$argument = $data->field_custom_field['lang value'][0]['value']; 
// parse the array to find your field
return $argument;
}
botris’s picture

I've managed to do this with an argument / contextual filter.
- Add a taxonomy term filter
- Use php code as default value

if(isset($_GET['arg'])) {
return $_GET['arg'];
} else {
return 'all';
}

Calling your webform like /webformurl?arg=30 (where 30 is your term id) works like a charm.

dman’s picture

Issue summary: View changes
Status: Active » Fixed

I've done this now in the Webform Views UI. Edit the "webform view" component and next to where you select the View, you can also pass in contextual filter values as arguments that get used by the view.

EG I can set up a webform that only lists items for a certain 'audience' type when the content is tagged appropriately.

The built-in views contextual handlers also work as Boris and Roulion above have found. They have access to the container node info, the path and other things that you may also use as filters. Using that method to grab a value from the incoming URL is probably even MORE useful than just configuring it on the form!
But if you want to define it explicitly, it's now configurable through the UI.
ALSO, the easy way is just to build a couple of displays in views that do your job, but it depends on how many variants you expect to have to re-use.

It's now pushed through to dev but may need more testing if someone wants to document their use-case in a way that can be replicated fully...

Status: Fixed » Closed (fixed)

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