Closed (fixed)
Project:
Entity Reference Autocomplete
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Oct 2014 at 02:42 UTC
Updated:
22 Sep 2015 at 15:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
liquidcms commentedhmm.. a bit of a pita to patch for this since the module uses entityfieldquery for its db search and there is no way to do a join (to the realname table) with EFQ.. ughh
Comment #2
slv_ commentedAs much as I'd like that feature, doing it cleanly means simply adding support for more customizable queries. While I've something in mind for that already, I lack the time to do that right now, and I'm not sure I'll be able to pick this up anytime soon :(.
Comment #3
slv_ commentedIn fact, I think I'm going to close the ticket rather than postponing, since this will be allowed when what i mention is in place, so no point of keeping it as something separate, which might be misleading.
However, you can still achieve what you want, since, even though there's no alter hook that gets the string passed by the user, it's relatively simple to inject your custom query there. I suggest you use hook_menu_alter() to override this entry:
In there, replace the "page callback" for some callback of your own. Then in that callback, check for the entity type, and if it's user, you can write your own code (or simply delegate logic to a copy of the original callback function, replacing just the bits you need). If it's not a user, then you can just delegate to the original entityreference_autocomplete_autocomplete_callback() function.
While it's a bit hacky, it's a quick way to get around the limitations of the 7.x-1.x version for what you are trying to do.
Best regards.
Comment #4
liquidcms commentedthanks for the idea.. that should work.
Comment #5
Derimagia commentedAdding patch for this. I added a tag to the query so that we can alter for realname.
Comment #6
Derimagia commentedPatch still needs some work to work 100% but it's pretty easy to implement. I'll continue to work on it.
Comment #7
Derimagia commentedAdding new patch
Comment #8
dpliscoff commentedPatch #7 over 7.x-1.8+2-dev and can confirm it works.
Comment #9
slv_ commentedHi all,
Not too sure about adding this one, although the approach looks certainly great. I don't mind adding the tags to allow for query alters, but I don't think this module should cope with logic to alter the query based on the data model from another module.
Derimagia, do you happen to know the realname maintainer, or would you mind opening an issue to support entityreference autocomplete? Happy to add the tags, but the realname-specific logic should be in there, and not here.
Marking as needs work for now.
Comment #10
slv_ commentedComment #11
Derimagia commentedOpened up a ticket here: https://www.drupal.org/node/2572691
Understand not wanting to have the query alter in this module, but if we can add the tags then that would be useful for other reasons as well.
Comment #12
slv_ commentedSure, of course. Would you mind re-rerolling a patch just with that?
Also, this:
$query->addMetaData('era_search', $last_label);
Can be:
$query->addMetaData('era_search_string', $last_label);
Just to make it obvious it is the search string entered by the user?
Thanks a lot for taking the time to open the other issue as well.
Comment #13
Derimagia commentedAttached is the new patch
Comment #15
slv_ commentedThanks for that.
Pushed to --dev branch. Rolling out a new stable release now. Thanks!
Will close for now, but feel free to reopen if the realname module doesn't consider adding the other part to his module.
Comment #16
slv_ commented