Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using selective filters with a node reference field the nid is displayed in the filter list instead of the node title. This makes the filters useless for this field type. This is not a problem when using a regular filter type. I am using Views-7.x-3.3.
Comment | File | Size | Author |
---|---|---|---|
#29 | views_hacks-show_term_titles-1608498-28.patch | 1.6 KB | sirko_el |
#28 | views_hacks-show_term_titles-1608498-28.patch | 1.64 KB | sirko_el |
#26 | views_hacks-show_term_titles-1608498-26.patch | 2.28 KB | jlyon |
#16 | actual_values.png | 19.17 KB | sioux |
#11 | views_hacks-show_term_titles-1608498-11.patch | 1.01 KB | PapaGrande |
Comments
Comment #1
tms8707056 CreditAttribution: tms8707056 commentedHere is a patch for views_handler_filter_selective.inc to add titles for node_reference fields. If there is a better way to do this, please speak up as this is my first patch.
Comment #2
harings_rob CreditAttribution: harings_rob commentedI have no possibility to apply the patch. Can you upload or do a codedump of the full file? so i can change the contents?
Comment #3
harings_rob CreditAttribution: harings_rob commentedI have applied the patch and it did not fix the issue, still displaying ID's instead of text.
Comment #4
farrington CreditAttribution: farrington commentedI think the problem is relevant to all sorts of references, at least I had the same problem with terms (showed tid instead of term name).
The patch was similar to that above. Perhaps change the issue title and summary?
Comment #5
harings_rob CreditAttribution: harings_rob commentedYes i managed to edit the patch to my needs (term names etc.)
Comment #6
clubminsk CreditAttribution: clubminsk commentedplease, post the patch here, many people is looking for your help
Comment #7
harings_rob CreditAttribution: harings_rob commentedIf you could tell me how to create a patch i'll upload the file
Comment #8
rolfmeijer CreditAttribution: rolfmeijer commentedInformation on how to create patches with git can be found at http://drupal.org/node/707484
Alternatively you could post your code here (presuming it’s not too long).
Comment #9
harings_rob CreditAttribution: harings_rob commentedComment #10
joachim CreditAttribution: joachim commentedPlease could you post changes as an actual patch file please? d.org has plenty of help resources on how to do this if you're stuck.
Comment #11
PapaGrandeI needed this too so I rolled a patch after a bit of cleanup of @tortelduif's good work in #9.
Comment #12
joachim CreditAttribution: joachim commentedThanks!
That helps hugely in understanding what change is proposed here.
Unfortunately, I can now see straight away that this patch won't work. The handler views_handler_filter_selective is applied to every database field that supports a filter, and not all of them are nodes.
$this->value_options could contain node ids, but it could also be user ids, term ids, or even bananas if that's the table in question. So just trying to load nodes based on them is a mistake.
As a side note, this looks wrong too:
'SELECT name FROM {taxonomy_term_data} WHERE tid = :nid',
You're not going to find node names in the taxonomy term table!
Comment #13
planctus CreditAttribution: planctus commented@joachim
Certainly this is not a global solution but just a temporary fix for those who are dealing with a specific need for an exposed term reference field or node reference one..
I had the first need and the code works since :nid is just a placeholder, if you look at the code at #9 in the loop the variable is defined as $nid, surely this is because the original piece of code was written for a nodereference field, but if you like, you might change it as $tid and then define :tid as the placeholder in the query, it will reduce confusion, but it won't change anything...
You're still right then, this has to be fixed for all the the references, not just one of them.
Thanks,
Da.
Comment #14
danielnolde CreditAttribution: danielnolde commentedThe proposed patch is a way too specific way to solve the problem.
What about taxonomy based filters on term_reference fields for a taxonomy based view?
A lot of use cases are not based on nodes in Drupal 7.
Could you generalize the solution?
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commented#11 fixes the issue
Comment #16
sioux CreditAttribution: sioux commented#11 worked for me- sort of... see attached. I have to select Any and Apply before the filtering will work.
Is there a way to configure so that step is not necessary, and the default list of locations is displayed by default - like it was under Drupal 6.
Comment #17
marcoka CreditAttribution: marcoka commentedfor information, this only solves it for taxonomy fields. if you add an integer list, it will show the keys instead of values. "selective filters" seems to be broken.
Comment #18
7wonders CreditAttribution: 7wonders commentedSeems to be the same case for users. Expecting username but shows UID.
Comment #19
Funksmaname CreditAttribution: Funksmaname commented#11 worked for me for a term reference field.
Thanks!
Comment #20
sioux CreditAttribution: sioux commentedBy using a combination of tips I finally have selective filtering of taxonomy terms working.
1. I (manually) patched the views filters selective file using the #11 tip above.
2. In my view, under filters, I selected content: name-of-my-vocabulary (selective)
3. I exposed the filter & made 0 selections -see tip #13, step 2 at https://drupal.org/node/1204240#comment-6792218
I have selective filtering with my taxonomy terms instead of IDs!
Comment #21
jpstrikesback CreditAttribution: jpstrikesback commentedNot to hijack but for anyone interested in this functionality specifically for Taxonomy Terms after trying this I went in a different direction and made:
Views Term Family
It has two filters:
Comment #22
kclarkson CreditAttribution: kclarkson commentedSo it seems that the patch provided is not the solution. Is this something that can be easily fixed ?
Is it as simple as changing a few variables ? If so could a nice codemaster hook this up as it is a pretty important feature for people who share a tag field among different content types?
@jpstrikesback
Is it possible to use ur code from ur sandbox module to help patch views hacks ? Also I noticed that the maintainer needs a little help, maybe u could collaborate to eliminate module duplication. Just a thought :)
Comment #23
jpstrikesback CreditAttribution: jpstrikesback commentedHey kclarkson,
Off the top of my head I don't think what I've done would be so helpful for patching this module, but if its taxonomy terms and restricting the dropdown to terms on content then Views Term Family has a filter for that. I don't think my module creates much duplication tho, it's higher purpose is for filtering views by a term and its nearby relations such as parent, children, sibling terms.
Cheers :)
Comment #24
kclarkson CreditAttribution: kclarkson commented@jpstikesback
Thank you for clarifying the differences. It sounds like your module is exactly what I was looking for so I will give it a go.
Comment #25
jpstrikesback CreditAttribution: jpstrikesback commented@kclarkson, great to hear, if you end up using it and you experience any issues please let me know :)
Comment #26
jlyon CreditAttribution: jlyon commentedThis worked great for me for taxonomy term selects, however I needed it to work for select list fields as well. The attached patch adds support for that. This is a patch against views_hacks-7.x-1.0-alpha1, which seems to include #1.
Comment #27
John Pitcairn CreditAttribution: John Pitcairn commentedPatch at #11 applies cleanly and works for me, showing taxonomy term names in the exposed filter menu.
@jlyon: please use git to create patches. Your patch is specific to your installation path and does not apply.
Comment #28
sirko_el CreditAttribution: sirko_el commentedAdded node titles to patch: views_hacks-show_term_titles-1608498-26.patch
Comment #29
sirko_el CreditAttribution: sirko_el commentedSorry about dpm. Deleted now.
Comment #30
kclarkson CreditAttribution: kclarkson commentedI am also confirming that patch #11 worked on 7.x-1-alpha1
@sirko_el I tried applying your patch but it said corrupt on line 12.
Comment #31
jonhattan#28 and #29 are not full patches. They are written over #26.
Comment #32
kclarkson CreditAttribution: kclarkson commentedwould be great if someone could combine 26 thru 29 so that it applies cleanly and we can get it submitted.
Comment #33
nasir.bd CreditAttribution: nasir.bd commentedI got nid instead of title in views exposed filter.
#1 patch, It is working file for me with a little change node_reference_views_options to node_reference_views_filter_options
// Modify value_options to include title for node reference fields.
Above code just copy & paste in below code
Comment #34
pearl.liang CreditAttribution: pearl.liang commented#33 works for me as well.
Comment #35
infojunkieThis module has been deprecated in favour of https://drupal.org/project/views_selective_filters. Please test there and reopen if necessary.