Active
Project:
Privatemsg Views
Version:
6.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2010 at 19:50 UTC
Updated:
17 Nov 2010 at 13:26 UTC
Hi,
Here's an actual issue I discovered. I've added user pictures to the default privatemsg_mailbox view in via the "Privatemsg: Author" relationship and the User Picture field. Unfortunately, this seems to break the thread into separate messages. I read this issue (http://drupal.org/node/735730) but am still unsure as to what is causing the threads to be broken into individual messages. Is there a way around this?
Thanks,
Thomas
Comments
Comment #1
pribeh commentedSo the threads are not broken into separate messages if I use "Privatemsg: Participant" as the relationship for the user picture but that doesn't provide the right display.
Comment #2
crea commentedMailbox view is tricky stuff because of GROUP BY etc. Can you post here exact query your view generates ?
Comment #3
pribeh commentedThanks for looking into this:
Comment #4
crea commentedThe problem is "users_pm_message_picture" is inside GROUP BY. Because user pictures are unique for every message, they break thread grouping.
Unfortunately, they can't be ouside of GROUP BY either: that would be invalid SQL. This requires special views handler most likely.
Comment #5
pribeh commentedHey Crea,
Thanks for looking into this. I assumed that something like what you describe was happening. How difficult would it be to write a views handler for this?
Thomas
Comment #6
crea commentedIt's not difficult. It simply requires someone to do it. But as a generic solution we might need something better. It would be awesome to have a relationship plugin that allowed to fetch field values in a separate query. That would allow us to use any existing field in GROUP BY queries using the relationship. Though I am not sure if this is possible.
For now I can recommend to output user pictures inside a template. That is much easier to do.
Comment #7
pribeh commentedWould I use a views template override?
Comment #8
crea commentedYeah or use Views Custom field or something like that (a module that lets to use custom php code as a field output). Just make sure that message author id is available.
Comment #9
crea commentedComment #10
twodI'm trying to do something similar, but using an image field from content_profile.module's user nodes. So I need two relationships instead of one.
The wanted fields are joined in by first adding a relationship with Privatemsg: Author, then another one for Node: Content Profile which has been set to use the previous Author relationship.
Then finally I add the CCK file/image field to the query via the Content Profile relationship.
The above (including some other fields) produces a query like:
That gives one row per participant in a thread, but I want one row per thread.
For this, pretty much all the groupings above are redundant. There's no point to group on pm_index_uid, any of the avatar (Content Profile CCK image) fields, the message's name, subject or new status.
The query I'm after would look similar to:
Which fetches what I need, but how do I make Views do that with the handlers provided by this module? The comments above indicate new handlers are needed, mind elaborating on that?
The query doesn't become invalid SQL because those fields aren't grouped by. Do the results really need to be grouped by those fields?
Comment #11
crea commented@TwoD
If there's a column in the query that is not aggregate function, it should be inside GROUP BY. Otherwise SQL is invalid. The examples you link show using of subquery which would require custom handlers too.
Comment #12
crea commentedOn a second thought, I think the linked technique is quite interesting: it could indeed allow to use regular handlers with our views, cause grouping would be isolated in a subquery. Making it a feature request because of that.
@TwoD: If you want to work on this, it should be a relationship handler. By selecting which fields/arguments/filters use the relationship and which don't, we would move them between the main query and the subquery.