I am looking for help in how (and whether it is indeed possible) to pass in an argument to the Views module which can update a field dynamically?

More specifically, I would like use a page like www.example.com/view/blue to pass in 'blue' and then select all users who have blue on a particular profile field.

Here's what I have now:

$view->filter = array (
array (
'tablename' => 'profile_companies',
'field' => 'value',
'operator' => 'contains',
'options' => '',
'value' => 'blue',
),
);

I'm wondering if there's some way to work with the Views module to change the hardcoded 'blue' to something like $arg[0] or %1, but I'm not sure if there's a way to do this directly from the module.

Thank you very much.

Comments

KingMoore’s picture

have you read this?

http://drupal.org/node/54455

youplatform’s picture

Hi KingMoore,

I've read this in depth and understand how this works for changing titles, which I've been able to do successfully.

The problem I have is in changing the value of a filter. In my case, I'm trying to run a free-form text search on a page, have the user type in the name of a company they want more information about, and then run a query in view which pulls a list of all users who have worked at this company before (using a "contains" search on a custom field I've defined).

The problem I run into is that when I type %1, $arg[0] or anything else in the 'value' box of the filter, I end up just searching for %1 or $arg[0], not the dynamic data. I'm not sure how to get around this.

Thank you.

KingMoore’s picture

I think the term 'arguments' is confusing you. I know it had me confused for a while. An argument actually is a filter, but a dynamic one. Try removing your filter, and using the argument to do your filtering. It's a bit hard for me to explain without having access to your exact implementation, but basically arguments are filters that take their context from a URL argument.

I hope that helps point you in the right direction.

youplatform’s picture

Thanks KingMoore - It doesn't quite click for me yet but I'll keep playing around with it and hopefully come up with some insight after a bit.

Take care.

timyager’s picture

had any luck youplatform? i am trying to accomplish a similar task and am stuck. i can modify $view->page_title as a test, but the second i try to add a filter, even if it's verbatim from an export of my view with the filter predefined i get no where. it goes without saying that it's pretty frustrating. :)