Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Could please someone say how to include login count of a user in a view. I took and cloned one of the user IP views and have now something I want with last login, online etc, but I cannot find the login count in the views UI.
Comment | File | Size | Author |
---|---|---|---|
#5 | views_field_login_count.user_stats.2.tgz | 2.18 KB | ñull |
#2 | views_field_login_count.user_stats.tgz | 2.24 KB | ñull |
Comments
Comment #1
ñull CreditAttribution: ñull commentedFrom the code I see that login_count is implemented as a token, but how on earth do you include a token in a view?
Comment #2
ñull CreditAttribution: ñull commentedAttached a hack to include login count in a view. I had a problem with duplicate values and apparently the DISTINCT function in views is not doing what it should ). The only work around I found was to remove the left join relation from the query. Either use the included patch user_stats.views.inc or patch it with login_count.user_stats.views.inc.patch
If there is a more elegant solution for the duplicate problem, then please contribute it. When a new Views release comes out, I will remove the work around and re-upload my patch here.
Comment #3
ñull CreditAttribution: ñull commentedComment #4
ñull CreditAttribution: ñull commentedComment #5
ñull CreditAttribution: ñull commentedAfter views 6.x-2.8 was released my work around became obsolete. Attached the new patch without it.
Comment #6
ñull CreditAttribution: ñull commentedPlease could someone review it?
Comment #7
Liam McDermott CreditAttribution: Liam McDermott commentedAh, thanks for posting this! I'm really swamped at the moment, but it'll get reviewed at some point in the near future.
User login count does suck pretty badly at the moment though; it literally only counts logins, not when someone leaves, comes back and resumes a previous session. Would be great if you created a new issue (and maybe even a patch) for that. If it's a problem.
Comment #8
aliciatheduff CreditAttribution: aliciatheduff commentedI tried this patch out, am I supposed to see the new field appear under the users category in views?
Comment #9
chuckbar77 CreditAttribution: chuckbar77 commented+1 subscribing
Comment #10
YK85 CreditAttribution: YK85 commentedsubscribing
Comment #11
Open Social CreditAttribution: Open Social commentedsubscribing,
I can't find the item in the views field list. What should I do?
I used views custom php field to include it via the api
But it looks like views chart doesn't like that
Comment #12
lukus@goalgorilla;
The custom PHP fields aren't actually calculated until the view is rendered as far as I know, which might be why it's not working the way you hope.
Comment #13
hockey2112 CreditAttribution: hockey2112 commentedHow would I modify the php code from #11 so that it is compatible with Drupal 7?
Comment #14
cferthorney@hockey2112 I'm going to work on this over the Easter break (This coming weekend) I think, as I need the feature for a work site. I'll apply a 7.x compatible patch (Haven't coded for D6 in years so won't be tackling that I'm afraid)
Comment #15
hockey2112 CreditAttribution: hockey2112 commentedThat sounds great, thanks!
Comment #16
Liam McDermott CreditAttribution: Liam McDermott commentedcferthorney, that sounds great. Hope you're having some luck getting this done, the Views integration was quite badly done in the first place (by me) and has suffered bitrot too, so I have a bad feeling quite a lot may need to be rewritten in the Views integration.
Also bumping the version to 7.x, as I can understand why you wouldn't want to work with 6.x.