Showing and filtering on uid isn't very useful so I wanted to add usernames. After some reading it turned out to be very simple:
I edited support_views.views.inc and added this:
// Assigned
$data['support_ticket']['assigned'] = array(
'title' => t('Assigned ID'),
'help' => t('The Assigned ID of the ticket.'),
'relationship' => array(
'base' => 'users',
'field' => 'uid',
'handler' => 'views_handler_relationship',
'label' => t('Assigned user'),
),
That is, I added the relationship part. Then I add that relationship in the view and it lets me both show and filter on usernames.
Hope it's useful to someone.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | support_views.patch | 620 bytes | toby.batch |
Comments
Comment #1
de3pimpact commentedWould it be possible to add a field based on the assigned user? When I add a field in Views, I could not select Assigned user, but only Assigned ID.
If I used your method above, what are the things I need to add in fields for Views and relationship to show the Assigned username instead of the assigned user ID?
Thanks
Comment #2
downtap commentedde3pimpact:
To clarify, here are the steps:
- Add code above
- Clear cache
- Go into your view
- Under relationships, add Support Tickets: Assigned ID relationship
- In your fields, and User: Name with a Relationship of Assigned user
Comment #3
toby.batch commentedI have a patch that allows the assigned user to be included as an association. It's basically your code but I've patchified it and added a sort handler.
Comment #4
de3pimpact commentedHi downtap
It is working now.
Thanks for the clarification.
Comment #5
rsevero commentedUsing the patch by toby.batch at #3 in one production site. Works as expected.
Comment #6
MisterSpeed commentedCommitted; thanks !
Comment #8
Sizzly commentedOkay. I added that code at the end of the file and it broke my site. Where should I add it? Replace the existing bit? Please help.
Comment #9
MisterSpeed commentedSizzly: just download the -dev version currently listed on the page, it already includes the patch.