I'm trying to display a view of all nodes tagged with any term from a vocabulary except the term passed in as an argument. This is similar in functionality to the negative filter for a taxonomy term except dynamic via arguments.
Is this possible?
Came to a dead end here: http://drupal.org/node/285304
Thanks in advance,
Michael
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | views-430462-8.patch | 11.78 KB | cdale |
| #6 | views-430462-6.patch | 9.38 KB | cdale |
| #5 | views-430462-5.patch | 9.38 KB | cdale |
| #4 | views-430462-3.patch | 9.95 KB | cdale |
| #2 | views-430462.patch | 1.54 KB | cdale |
Comments
Comment #1
merlinofchaos commentedUnfortunately this is currently not possible with an argument. =(
Comment #2
cdale commentedCould this maybe be achieved with the following patch? I haven't actually tested this, was just a thought I had...
Comment #3
mpaler commentedHi cdale,
I'll give this a whirl this weekend when I get some free time. Looks interesting!
Mike
Comment #4
cdale commentedI've created a more complete patch. Does this seem like a good idea? Is the approach I've taken acceptable?
Comment #5
cdale commentedCleaner patch.
Comment #6
cdale commentedApologies for not testing the last patch. This one is tested, and seems to work quite well.
Comment #7
mpaler commentedHi cdale,
I've installed the patch on the latest dev build with no problems. I can see the new "Exclude the Argument" selector, however, even after trying a variety of settings, I can't seem to get it to execute in the query. Perhaps I'm not understanding how you meant the selector to be used.
Rather than explain all the variations I attempted, I'm wondering if you could explain or screen shot your argument settings for your working example.
Many thanks,
Mike
Comment #8
cdale commentedAhh, I missed a few places for many to one arguments. :) New patch attached.
Actually, I've found a few circumstances playing with the taxonomy arguments where this won't work as expected. For example, it will not show nodes that have not selected any taxonomy terms (But are able too) Which it probably should.
Not sure how to solve that just yet, so I'm marking this as CNW.
Comment #9
cdale commentedLet me know if there is anything else that does not work. I'll keep digging. :)
Comment #10
mpaler commentedThat one worked. Unfortunately, it appears it doesn't work for nodes tagged with terms from two different vocabularies.
For example, you have three nodes all tagged with different terms from the same vocabulary. If you select "Exclude the Argument" selector and pass in a term (I've been doing term id), the node tagged with that term id will be excluded as expected from the view.
However, if you go back and tag that node with a term from a different vocabulary, it is no longer excluded from the view. Seems like that isn't the expected behavior.
Try it and let me know if I'm not just crazy. Thanks for working on this!
Comment #11
cdale commentedThis could be related to the problem I described above. An example might help.
I have a vocabulary "pets" with the terms "cat" and "dog".
I have a content type "People" with the following nodes, tagged as shown.
Jane - Cat
Jake - Cat
Bill - Dog
Beth - Dog
Paul - [NONE] - i.e. the taxonomy is not required, meaning not all people have to have pets. :)
Now, if you create a view of people, with an argument for pets, you would expect that when you don't specify the argument, that all people would be shown. This works fine.
If you then specify you want to see all people who have cats, by passing in an argument, you would see Jane and Jake, this also works fine, and is the default behavior.
The problem comes when you say I want to see all people who DON'T have cats. You would expect the result of that to show Bill, Beth, and Paul. This will however not be the case. Paul will not show up, even though he really should.
This is the problem I'm currently thinking about how to approach. It should be that whenever you select the "Exclude the argument" option, that the view then shows the EXACT inverse of results as to when "Exclude to argument" is not checked. This is currently not so simple because of the way views does its table joins, with INNER etc... This means that before you even think about filtering, the users who do not have "pets" are already excluded.
The only way around this (Without a patch which I'm thinking about a way to write), is to make the "pets" taxonomy required, and add a "no pets" term or something like that.
This does not exactly match the problem you're seeing, but I think it is related. I'll keep playing and post back here when I think I have something.
Thanks for testing.
Comment #12
gsemko commentedThis could be made by query alter hook. You need to change module name, view name and argument index.
Comment #13
mpaler commentedThanks for sharing.
Comment #14
summit commentedSubscribing, still investiging. Would be great if there was an option within taxonomy arguments "Exclude the argument itself with using the depth more or less than 0.
Greetings, Martijn
Comment #15
summit commentedHi, May be using the way this was build can help: http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-cre... so using php code with views2!
greetings, Martijn
Comment #16
esmerel commentedOK folks in this one - is this still valid? If it is, check it against the current release.
Comment #17
esmerel commentedNo updates in more than 30 days.
Comment #18
mcpuddin commentedFor those looking for this solution, #12 works very well. If someone has time, reviewing/fixing up patch #8 is the eventual elegant solution for this problem.
Comment #19
spgd01 commentedAny news on this? I would love to have this feature. If not how would you use #12? where do you put the code? Thank you.
Comment #20
doublejosh commented#733686: Add exclude option to other argument types
This does not work in Drupal 6 & Views 2.x, but a screenshot makes it looks like it does in Drupal 7 & Views 3.x
There is this as well: Views Exclude Previous, though it's not quite as specific.
(I've used it as my solution.)
Comment #21
dunx commentedMany (belated) thanks to gsemko #12. I've spent 3 days trying to work out how to exclude taxonomy terms from a previous pane in subsequent panes. I thought I was heading off down the road of custom views handlers to negate the select. Seemed a bit overkill to change "node.vid IN (SELECT..." to "node.vid NOT IN (SELECT..."!
So now I have two "Taxonomy: Term ID (with depth)" arguments for my view and pass the two sets of term_ids from my panel config. I rewrite the second of those using hook_views_query_alter to be a NOT and all works fine. I did have to set up a default value of 9999 in the view config for the second argument as for my first pane, I don't want to exclude anything.
If anybody needs a deeper explanation, hit me back and I'll expand.
Comment #22
mustanggb commented