Not sure this is a bug or by design, but is not working as I would expect.
Description of issue:
- defined two taxonomies, voc1 with terms v1t1, v1t2 and v1t3 (say they have taxonomy term IDs 11, 12 and 13 respectively), and voc2 with terms v2t1, v2t2 and v2t3 (say these have IDs 21, 22 and 23 respectively).
- creating a page view where I am filtering as following:
- taxonomy terms for v1 "is one of" v1t1,v1t2
AND
- taxonomy terms for v2 "is one of" v2t1,v2t2
- am adding an argument taxonomy term name "sorted as view"
- saved the view as "myview"
When I am loading url http://mysite.net/myview, I can see terms displayed as expected (summarised with totals by voc1). When I click on each of them, or provide them as arguments (say, http://mysite.net/myview/v1t1), again it works as expected, displaying a list with nodes tagged with any of v2t1 or v2t2 from second vocabulary.
Now, what I wanted to do is to add a second argument (also as taxonomy term name!) to further refining by second term and only get the nodes tagged by that particular term. Basically, I want to use views to get nodes that I would display when accessing say, http://mysite.net/taxonomy/term/11,22 BUT using views interface AND term NAMES instead term IDs (11 is the ID for v1t1 and 22 is the ID for v2t2).
What happens in views, is that as soon as I add the second argument as "taxonomy term name" like the first argument, then try to access a path like http://mysite.net/myview/v1t1/v2t2 I only got a blank page. I of course double checked and first tried to access http://mysite.net/taxonomy/term/11,22 which returns nodes as expected.
HOWEVER, if I replace second argument with "taxonomy term ID" instead "taxonomy term name", then use a mixed path like http://mysite.net/myview/v1t1/22 (again where 22 is the ID of taxonomy term v2t2), this time it displays correctly... (?!?!)
So my question is: is there possible to use views as described above with BOTH arguments as names, instead this mixed path (first arg as name and second one as ID)?
Am new to views and I was first reading the views docs, but found nothing to help in my particular case. I really appreciate any suggestion to help me move on.
Thank you.
Comment | File | Size | Author |
---|---|---|---|
#17 | multi_termname_summary.patch | 1.17 KB | alanic |
#15 | multi_termname.patch | 1.04 KB | alanic |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedThis makes my head spin. =)
Views has some long-standing problems combining different taxonomy filters, so unfortunately what you want to do isn't going to work all that well until I come up with a better solution for all of the possible taxonomy combinations.
Comment #2
marcoBauli CreditAttribution: marcoBauli commented+1
same need for me. I tried same "mixed" solution (
http://mysite.net/myview/v1t1/22
), but it's problematic.Advantages of using two taxonomy term names instead of a mix of a taxonomy term name and one ID are:
cheers
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedI realize this is a big want, but it's also hard, so don't expect this to work better any time soon.
Comment #4
marcoBauli CreditAttribution: marcoBauli commentedThanks for precising Merlin.
Views module is just *great* as it is, these are only some small refinings to a piece of genius :)
Comment #5
mvcThis feature would be a very welcome addition to Views. In the meantime, I've been able to get something similar working via custom argument handling code (details here).
Comment #6
MichelleI want to chime in for requesting this and bumped the version up. Just ran into this and couldn't figure out why it wasn't working until I found this issue. If this could somehow be made to work, that would be awesome.
Michelle
Comment #7
Leeteq CreditAttribution: Leeteq commented+1 and subscribing
Comment #8
Summit CreditAttribution: Summit commentedHi,
+1 to get this working!
The solution with the argument handling code is not working for me. I don't know why.
The views and panels modules are great, with this feature working it would be able to build a panel using views with more than one taxonomy term as a argument.
greetings,
Martijn
Comment #9
nath CreditAttribution: nath commentedThis is something we need for our site as well.
Comment #10
thelizardking CreditAttribution: thelizardking commentedI was working with views and was trying to incorporate two taxonomies in a view. I am basically embedding two views in the main view. The two views are to be sorted on a different taxonomy. I am using argument and filter. The content is organized based on products and models and FAQs are further organized based on sub FAQ types. I need to sort depending upon the products, models as well as FAQ issues.
I am going to create my own script to make my solution work and later look on this issue and try to fix the problem. If anyone has a solution or is working on one, please respond and I can contribute to the solution rather than working from scratch.
Comment #11
thelizardking CreditAttribution: thelizardking commentedI used CCK fields to create sub-topics and used filter based on this field.
Comment #12
Caleb G2 CreditAttribution: Caleb G2 commentedsubscribing. Glad to find out that I wasn't going nuts at least...
Comment #13
coupet CreditAttribution: coupet commentedsubscribing. good feature to have.
further details on concept and implementation challenges would be welcomed.
Comment #14
alanic CreditAttribution: alanic commentedI'm working on this right now. I thought I'd share what I have.
Here is the query generated for one term name argument.
Here is the query generated for two term name arguments.
At first glance, one obvious correction is "term_data2.name = 'term2'", but of course this does not solve it since both term names are mapped to the same term_node.tid. Here is the fixed query:
Since there are term_node.tid and term_node2.tid, we can really enforce two terms.
So, if we can make the module create this SQL, this should be fixed. I'll see what I can do.
Btw, shouldn't this be a bug report instead of a feature request?
Comment #15
alanic CreditAttribution: alanic commentedOk here is the patch, to be applied to the current release (views-5.x-1.6). Works for two taxonomy term name arguments, no reason it shouldn't work for more.
I hope this helps all the people subscribed here! :) Let me know of any issues.
Comment #16
alanic CreditAttribution: alanic commentedForgot to change status to patch. Also making it a bug report.
Comment #17
alanic CreditAttribution: alanic commentedHere is another patch that will fix the summary generation. Right now when there are more than one arguments, not all but at least one argument is provided, and summary is selected for default action, the output is blank. This fixes that to be how it should be: links of possible terms that the current filtered group of nodes have. You will, however, see the currently selected terms in that list. This is a result of the ambiguity of having two term arguments. If they were restricted to vocabularies it wouldn't be ambiguous. Which I also have implemented and I'm planning to provide it once it looks better, let me know if you need the current code for it.
This patch should be able to be applied before or after the other patch I posted.
Comment #18
Summit CreditAttribution: Summit commentedHi,
I will try your patch.
Is this patch also to use arguments on the filters?
Right now I can only set the filters manually related to taxonomy terms. That's why I am asking this.
I will give you feedback on the patch later this week.
Greetings,
Martijn
Comment #19
merlinofchaos CreditAttribution: merlinofchaos commentedThe reason that I've never committed a patch that does this is because this version will break the interaction when you add the taxonomy term field to the view.
Comment #20
Summit CreditAttribution: Summit commentedHi Earl,
So what to do? There is a argument handling code which says to help to support multiple term names input as arguments: http://drupal.org/node/54455#comment-239583
I tried it and it worked for views, but panels 2 doesn't like it yet. See http://drupal.org/node/192624 for my bugreport for this specific argument handling code and my view which will not save in Panels 2 (hopefully not something stupid on my side...).
Will this be the short term solution to use? Instead of the patch in this thread?
Greetings,
Martijn
Comment #21
alanic CreditAttribution: alanic commentedRe: Martijnhaan
Thanks for considering the patches. I didn't do anything about filters. In fact I'm not sure I understand what needs to be done about filters. What does "using arguments on filters" mean? I'm probably missing the point because I didn't use filters that much. All I know is that filters on taxonomy names can be set manually by the admin, or when they are exposed they can be modified by the user. I'd appreciate if you could tell me the scenario you are referring to.
Re: merlinofchaos
What do you mean "break the interaction"? Again I'm missing the point and would love some explanation.
On the quest to understand what I'm missing, I created two term name arguments and two term name filters, and they all seemed to work fine together. I exposed one of the filters and it was still fine. It wouldn't let me expose the other filter anymore but I don't think that's what you mean.
Comment #22
merlinofchaos CreditAttribution: merlinofchaos commentedThe easiest way to is for you to see it; use this patch, create the filters + the arguments, and then enable the taxonomy term field (that doesn't show multiple terms). Be sure to use this on a system where nodes have multiple terms.
Comment #23
alanic CreditAttribution: alanic commentedI just did that and it works perfectly. Since you didn't provide enough detail I'll provide more to make sure I did what you called for:
* In views UI I created a copy of frontpage,
* removed the default "Node: Feed Selector" argument
* added two "Taxonomy: Term Name" arguments
* didn't touch the two default filters "Node: Published" and "Node: Front Page"
* added two "Taxonomy: Term" filters with "Is all of" and selected a single term for each filter that is different from the other
* went to the url, since arguments were not provided I got summary links
* I clicked on them to provide two arguments, I chose ones that are different than the ones I chose for filters
* The page had two arguments in the url and it displayed three nodes from the database that had all four terms (two terms from the arguments, two terms from filters)
* There are many other nodes in the database that satisfy subsets of those four but none of them showed up as expected
So, as I said it worked perfectly. I'm doing this on a temporary installation so if you want to take a look I can give you the URL and the admin password. Let me know if this is not the scenario you were talking about.
edit: per our irc chat today this case covers it and there is no apparent problem with multiple arguments and multple filters.
Comment #24
Summit CreditAttribution: Summit commentedHi,
So this is the solution right now for multiple term names as arguments?
With filters you can set depth, say 3 depth means that all nodes with a specific to choose taxonomy term AND all the nodes with more depth taxonomy terms will be shown.
Until now I can only set this manually as admin.
What I would like is that with typing in the arguments the setup filter on top level with depth and vocabulary chosen gives the wanted situation.
So an example is:
Vocabulary regional
Taxonomy term: England
Taxonomy subterm: London
Taxonomy subsubterm: Banking
Taxonomy subterm: Manchester.
With typing ins www.example.com/england/Londen
The nodes should come up from Londen with two Arguments Taxonomy Terms set.
The nodes should come up from Londen And Banking with also the Filter set to Vocabulary Regional and Is-all-off with depth 3.
Is this doable?
greetings,
Martijn
Comment #25
alanic CreditAttribution: alanic commentedOh I see, you want the depth option for term name arguments. There is already an option for the number of characters, and there can be only one option. I guess another argument type needs to be created for that. I think similar code from filters can be used for this purpose. Since I don't really need this I won't work on it for now, but I would be glad to help out whoever tries to do this.
I also think that this depth thing is not related to the original issue here and needs a new feature request entry.
Btw, here is the query created for the two argument and two filter case with the patch. As you can see all arguments have their distinct joints.
Maybe a fix for filters in order when there is no depth argument. The node_hierarchy joins seem unnecessary.
Comment #26
Summit CreditAttribution: Summit commentedHi,
I installed the patch, and it is giving the following errors:
It is completely not working on my argument handling code for filter (blank page). I just don't get it right... see: http://drupal.org/node/163912#comment-637432
How can I use the argument handling code for two terms to be able to show then:
1- all nodes which have those terms as tags, and because of a filter with depth 3;
2- also show the terms "under" these tags?
(May be I need to set a different issue for this, if so sorry to fuzz about it on this thread).
But what I want is that because of using the terms as arguments the nodes ars shown with both terms tagged (your patched solution, great!) AND the nodes with the two terms as filter with depth 3, so all terms underneath the both terms are shown.
For example the url www.example.com/schools/england/london
Should show all tagged nodes with england AND london Your solution, right?
And show the nodes tagged with all nodes with are "under" london situated because of using a depth of 3. => on this argument I would like to set the argument handling code for the filter.
Greetings,
Martijn
Comment #27
alanic CreditAttribution: alanic commentedMy patches only change views_taxonomy.inc in the views module, so I'm not sure if those warning messages are related to my code at all.
As far as I know, "depth" option is only in filters. Filters and arguments are ANDed together. Therefore you can't have what you explained there.
Yes it should show all nodes that have england AND london tags, but this means that you can't have any node that does not have england and london together. No tags "under" london will be shown if the node does not have the tag "london". That's how arguments and filters work.
Of course if someone adds the "depth" option to arguments what you said could be possible.
If you think there is a specific case that term name arguments are not working well with filters I would be glad to look at it. But don't forget that they have to be AND'ed. So, you can only have tags "under" certain term using filters. Once you put the term name in the argument, you can't have terms "under" a term anymore.
Comment #28
Summit CreditAttribution: Summit commentedHi,
Thanks for your explanation!
I get the filters behaviour to make a view for every filter I need. But this way I will have a lot of views with only the filters altered every time.
The Filter functionality works as described. If I Filter a vocabulary on a top-lever taxonomy term with depth 3, the Nodes with this taxonomy term AND the nodes with taxonomy terms UNDER this term (so the subterms themselve are not in the url/arguments) are shown.
This manually to add functionality I would very much like to have automated. So with one view I can build all my wanted view-output, only by using the same arguments! If you know the argument handling code to get this done, it would be great!
Thanks for your patch and explanation!
Edit:
I tried a different approach to get my filter available (My vocabulary = 109):
Now I got errors in my views_taxonomy.inc, with the patch:
What do I do wrong, is the argument handling code incorrect?
May be it has to do with the patch, thats why I post the comment here.
Thanks for getting into this!
Greetings,
Martijn
Comment #29
Summit CreditAttribution: Summit commentedHi,
I think the error was in my argument handling code.
It is still not working, but I think I am getting close. This is my argument handling code now:
What I want is that the url www.example.com/view_url/foo/bar the foo (arg(0)) is used as filter-value. Foo is a taxonomy term in the vocabulary 109. I am trying this now with the above code, but it still isn't doing what I want, namely filter on the taxonomy term foo :( so that all nodes with foo,
Please help. I am allmost out of options now how to get this done..
Greetings,
Martijn
Comment #30
Summit CreditAttribution: Summit commentedHi,
Will these patches go in: http://drupal.org/node/77543#comment-633801 / http://drupal.org/node/77543#comment-634685
I will put it in production after these go in off course.
Until now no errors because of the patches as feedback to Alanic :)
greetings,
Martijn
Comment #31
Summit CreditAttribution: Summit commentedHi,
It looks that, thanks too Dmitry, I have a argument handling code, which works for two taxonomy terms now, without patching views as discribed above!!
What it does is that it filters the content to the first argument code and its subterms, and uses the second argument code to keep within the scope of this. So for example in my site: http://www.gratis-informatie.nl/over/wintersport/frankrijk will give all information related to wintersport (and all subterms) within frankrijk (france in dutch :)
I use the following argument handling code:
Could someone please comment on this. Is it true that the patch is not necessary any more, or do I see something wrong?
Does the patch do more, other things that I am not aware of?
Thanks in advance,
Greetings,
Martijn
Comment #32
alanic CreditAttribution: alanic commentedAs far as I can tell, that argument handling code is using the terms selected in arguments to change filters in runtime. Which is maybe not the most efficient way to do it because you probably will have two extra joins in SQL, but I guess it's fine. I didn't try it, but in fact I'm a little surprised to hear that this works because I expect the arguments and filters to be ANDed, but if it works that's fine.
The patch is functionally equivalent to it except it doesn't require those filters (probably 2 less joins), supports correct summary generation when arguments are not all filled in, but has no depth option.
Comment #33
Summit CreditAttribution: Summit commentedHi Alanic,
Thanks for your remarks on my code. And the depth is exactly what I needed. So without depth I would use your patch. And Yes the depth is working!
But if you could patch that also the depth is working..than your patch would be what I will use!
Greetings,
Martijn
Comment #34
Summit CreditAttribution: Summit commentedHi Alanic,
I tried your patch and my own argument handling code. It get stuck by terms, where you put a "-" between to words.
Like the term: alpe-dhuez in my situation.
Did you get your system working with 2 arguments and a "-" between words for one term? Or do you also have this?
Thanks in advance for your reply!
Greetings,
Martijn
Comment #35
alanic CreditAttribution: alanic commentedTerm names with dashes work for me.
Comment #36
jefbak2 CreditAttribution: jefbak2 commentedIt is really hard to figure out where to post on this issue but I just setup a whole taxonomy to use cck taxonomy fields and views to dispay and sort by Client Name. I don't have an option to sort of course.
So if I setup a text field in CCK instead I could sort on it?
Comment #37
jeff h CreditAttribution: jeff h commentedI don't know why you say "of course" :) It seems to me logical that, since taxonomy terms have weights and thus have an order, that you should be able to sort a view's output based on a taxonomy vocab.
But yes, if you put a CCK dropdown in your content type, I do believe you will be able to sort your views result on this.
Comment #38
gravit CreditAttribution: gravit commentedMerlin - would the following be a possible option?
Currently the views module allows filters by not just term name, but a term name in a specific vocabulary.
However, for arguments, there is only the generic option for "taxonomy: term name".
How difficult would it be to add in the ability to have taxonomy arguments specific to a vocabulary - just like the filters. Or to ignore certain vocabularies in the arguments - And would this solve the problem? It seems that it would in my particular case where I want to filter by one vocabulary, but customize the view url by another.
Comment #39
catchComment #40
jefbak2 CreditAttribution: jefbak2 commentedI guess the ways to sort are unclear for me sometimes.
I setup a view only to find that my vocab term does not show up but is generalized for the sort criteria.
I need to sort on an arbitrary report date field (not the publish date of the node) which I am using the calendar module for, and on Report type which can be a taxonomy field or a taxonomy term in the views Fields section. The field version has sort functions, but the taxonomy term does not.
In views Sort Criteria I also have the choice of using a generic taxonomy term with no specifiable term or I can choose the taxonomy field version which does include the report type.
This can get confusing for me very quickly as you can tell.
When should I set sorting in Fields and when should I use Sort Criteria instead? Using both seems to be problematic for me.
In views I need to be able to make the sort flexible so that that the view can default to Report Type and then Newest date first.
Comment #41
catchjefbak2, please open a new issue for this support request, this one is long enough as it is, and has nothing to do with sorting.
Comment #42
jefbak2 CreditAttribution: jefbak2 commentedSorry Catch, these issues can seem very similar to me. Not black and white.
I will repost.
Comment #43
fumanchu182 CreditAttribution: fumanchu182 commentedFor our purposes I wrote an argument handler for the specific view. It is a quick way of finding the taxonomy term associated with the taxonomy id (tid). It is as follows:
One other aspect of the view we are going to change is the way the SQL is logically OR'ed together. We would like it all to be logically AND'ed. I have been poking around in views_query.inc but is this the right file to be poking around in (have only given it a brief glance and haven't changed any code yet). Also what would be the game plan to create this logical functionality without breaking other views ability to logically OR terms/term ids together?
-A
Comment #44
patchak CreditAttribution: patchak commentedhey there Alanic, does this patch allows to use two term names as arguments on a single view?? How can I set it up ?? Do I need to add two times the "Taxonomy/term" argument, or I need to add it only once in the view's setup??
This is pretty interesting feature btw, will try and review the patch tonight.
Patchak
Comment #45
alanic CreditAttribution: alanic commentedYes, my patch allows you to add two of those and makes them work as expected. No you shouldn't add one if you want two. I'm on holiday right now, so I can't comment more in detail before 15 days. HTH.
Comment #46
dugh CreditAttribution: dugh commentedComment #47
Summit CreditAttribution: Summit commentedI do not think you need this patch to get this working.
I didn't use this patch, only smart working argument handling code...Views is such a great system, thanks to the good great mity MerlinofChaos!
Look at www.vindtocht.nl/over/kerst/nederland and www.vindtocht.nl/over/kerst/europa.
The terms you type in after the view "over" shows the resulting view-output.
But of course ok when it works also with a patch, but I like the flexibility of normal views update.
As long as this patch is not committed I will use the argument handling code.
Could it be that may be my method is more cpu-using? I don't know.
Open for discussion about this.
Enjoy your holidays!
greetings,
Martijn
Comment #48
daniel.hunt CreditAttribution: daniel.hunt commentedI'm interested in this too - subscribing
Comment #49
Misange CreditAttribution: Misange commentedCould you please summarize what you did in views, what code you wrote and where ? I am trying to do exactly what you describe (however in views2 and drupal 6.6) but fail. This thread is very long and somewhat confusing for someone discovering Drupal.
Thanks for sharing
Misange
Comment #50
alanic CreditAttribution: alanic commentedIt's been a long time since I did this and I'm not willing to work on it right now. But you can download the version I used and look at the patch files to see what I've changed. Patch files are the exact answer to the question "Could you please summarize what you did in views, what code you wrote and where?". Just open it with a text editor and take a look, they have line numbers and line change information. The lines starting with - are the ones that are removed and the lines starting with + are placed instead. Other lines are there to give sense of context.
Comment #51
merlinofchaos CreditAttribution: merlinofchaos commentedThreads for Views 1 won't help you at all for Views 2; they're basically different pieces of software.
Comment #52
esmerel CreditAttribution: esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.