Needs work
Project:
Drupal core
Version:
main
Component:
user system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
8 Sep 2015 at 00:59 UTC
Updated:
19 Dec 2022 at 13:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
flaviovs commentedComment #3
flaviovs commentedComment #4
cilefen commentedPlease check if this is an issue with Drupal 8. If so, it must be fixed there first according to the backport policy. If it is, move it to branch 8.0.x-dev and tag it “Needs backport to D7”.
Comment #5
drupalove commentedYou can theme the results using the ol class of user-results.
You can extend or make changes to theme_search_results() which uses a template as you mentioned.
Of course, the same applies to theme_search_result().
After applying the patch I still see the formatted username.
Please enlighten me as to how we will benefit from this change.
Comment #6
flaviovs commented@cilefen, I will do the 8.x check as you instructed me. Thanks.
@drupalove,
search-result.tpl.php(and it's preprocess cousin) only have access to 'title' (user name) and 'link' (a link to the user profile) values when presenting user search, so it is virtually impossible to display any additional information about the found user.For example, there's no way to display user pictures in the user search result (a very common use case, BTW).
Contrast with node search which (among other things) inject the node object in the results. In this case, the themer has total freedom to use information from the node to assemble and theme the node SERP any way s/he like it.
This patch does not introduce any visible change. It only inject the user object in an 'account' variable, so that it can be used by themers.
Comment #7
drupalove commented@flaviovs - unlike the node I think the user is not indexed, which still has no effect since developers can search index it if they want.
Although there are several workarounds, this is very useful. Thanks!
Comment #8
flaviovs commented@drupalove, yep users are not indexed. But user.module exposes hooks to the core search interface, so you get user search anyway.
I realize that is very easy to implement a Views view that can search and display users in any conceivable way, but it is not easy to integrate this to the core search interface (one reason is that by using Views you search UI must use exposed filters, which pass elements in the query string, whereas core search uses the search/user/keywords path).
Comment #9
drupalove commentedI'm in support of your patch just waiting for you to check Drupal 8 as suggested by cilefan.
Just for info, beside views, we can load the user by its unique username if the uid is not available and we wouldn't do it in the template. I've seen people also using display suite.
Comment #10
flaviovs commentedHere it goes, the same patch against 8.0.x.
Yeah, but if you use a module like Realname which hides the actual user name behind another field -- and this allows you to have duplicate "user names" -- then you are lost. (Been there...).
Comment #11
drupalove commentedI'm sure cilefen will be pleased with this.
Comment #13
flaviovs commentedPatch applies cleanly in my updated 8.0.x branch, so please check again.
Comment #15
flaviovs commentedOk, here we go, rerolled to apply cleanly with
git apply.Comment #27
smustgrave commentedComment #28
karishmaamin commentedComment #29
karishmaamin commentedComment #30
sahil.goyal commentedFound that provided patch is not getting applied to the version 10.1.x so i rerolled the patch and make it compatible with the current version also attaching the reroll file along.
Comment #31
sahil.goyal commentedfixing the CCF error for the #30
Comment #32
sahil.goyal commentedComment #33
smustgrave commentedThank you for interest in the issue but you will see it was tagged for needs tests.
Please read all comments and tags when changing statuses thanks.
Comment #34
smustgrave commented