Hello,
I am upgrading to Drupal 6 at the moment and have a problem with the switch from Views1 to Views2: I either need more argument operators (contains any word, contains, <=, >=, contains not) or a method to change a filter through an argument. As it seems, none works in Views2. Perhaps someone can give me some ideas and help…
Here is the situation in Views 1 / Drupal 5:
I have several views on my website (blocks and pages) that use the arguments code to get filtering information, change the information in some ways and than call a filter with that information. The filters mostly use the operators "contains any word" and "contains".
Example in Views 5:
I have a node-type for Restaurants. There is a CCK-text-field in this note-type where the type of the Restaurants are stored in a comma separated line (for example "Italian, International").
The similar-Restaurants-block gets its filtering information through the following code in its arguments api:
if (arg(0) == 'node' and is_numeric(arg(1))) {
$node = node_load(arg(1));
…
$view->filter[2]['value'] = strtoupper($node->field_type_rest[0]['value']);
…
}The called filter[2] uses the operator "contains any word".
So if a node of an italian restaurant is shown, other restaurants that contain the word "Italian" somewhere in their CCK-text-field "type_rest" (also Restaurants with the type "Italian, International, Mexican" for example) are shown in the similar restaurants block.
Now to Views2:
I am not able to achieve the same functionality. I have tried so far:
1) Arguments: Works generally. But the only operator seems to be "equal to". So a Restaurant with the type "Italian" only brings up other restaurants with the exact same type "Italian" in the similar-Restaurants-block and no restaurants with the type "Italian, International, Mexican" for example. So Arguments are not a solution for me, if they can not have other operators like "contains any word".
2) Calling Filters through arguments. That does not seem to work at all.
I hope it gets clear what my problem is ;)
Is there an easy solution for adding other operators in views2 arguments or for calling a filter through an argument. I have been working on this problem for some hours now and found no solution so far. It was so easy to do with Views1 and is so difficult with Views2 :(
Comments
Comment #1
MJH commentedThis method of calling views with arguments seems to work with my blocks:
http://programmingbulls.com/drupal-6-revisted-passing-arguments-through-...
But it would be much better, if that could be made through the views user interface as it was in Views 1...
Comment #2
merlinofchaos commentedIt would be nice, but unfortunately filters are no processed before arguments and so arguments cannot modify them. There's not really much that can be done about this given the new architecture.
Comment #3
zejkee commentedHi all.
So have the drupal 6.14v: views page, 3 filters([0-2]) and 1 argument.
filter #2 has the operator = "starts" and value = ""
all that I got is the changing the argument by $handler->argument.
But unfortunately no one example of code I've founded CAN'T change the filter value.
I've tried $view->filter[2]['value'] and even with the name of the filter $view->filter['title']['value'] - but it doesn't work.
Does anybody know how to change the filter by the argument php validator?
Or who knows how to change argument operator(not filter operator) from "=" to ">=" for example??
I looked in lots of materials, I'm not a lasy person, but unfortunately there is no ideas in my head=)
thx to everybody
p.s. Sorry for my English.