Closed (fixed)
Project:
References
Version:
7.x-2.x-dev
Component:
Code: node_reference
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
26 Apr 2011 at 20:38 UTC
Updated:
5 Jan 2012 at 23:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
wodenx commentedOld thread, I know, but how about hook_query_alter() see this discussion.
Comment #2
wodenx commentedActually, as I think about, that solution is problematic because there isn't enough context. It would be great if the $field object (and maybe the $options as well) could be added to the query as metadata - something like:
in _node_reference_potential_references_standard(), after line 752 of node_reference.module.
The Views integration is terrific, but sometimes you just want to write a lean query without all the overhead - especially for sites that have no other need for Views.
Comment #3
geerlingguy commentedDitto and subscribe. Would be an awesome feature, and the query alter idea would probably be the most robust way to do it... I think.
One way to hack around this currently would be to set up a view to do most of the grunt-work, then use a query alter on the actual views query to go the extra mile. Of course, you'd still need to use Views to get started (but seriously... who doesn't have Views installed on a Drupal site? ;-)
Comment #4
mstef commentedAlright, Views3 does have OR filters, but this could still be a decent feature.
Comment #5
rickvug commentedIn regards to #2 see the patch at #1256280: addMetaData for query in node_reference_field_prepare_view() which adds more meta data to the query so that it can be properly targeted using hook_query_alter. The patch looks good to me but it would be nice to have more feedback before marking it RTBC.
Comment #6
s_leu commentedmade a patch containing the proposed additions of #2. closing #1256280: addMetaData for query in node_reference_field_prepare_view() as duplicate.
Comment #7
berdirComment #8
berdirDisclaimer: s_leu and I are working together.
The change is simple enough and allows you to do field specific alterations without having to mess with views.
Edit: Note that the issue that was marked as a duplicate added an id (something that the module already does ) but didn't add the options. That's why we've chosen this approach.
Comment #9
yched commentedSure, why not - just in time for the 7.x-2.0 release :-)
Added the corresponding in user_references, committed the attached patch.
Thanks !