Is there a way to use 'user points' with the module view? I couldn't find any field from 'user points' in view, my intention is to add more information from the profiles than the /userpoints link.

BTW this module is very good.

Thanks
Alex

Comments

d0t101101’s picture

Version: 5.x-1.1 » 5.x-2.10
Category: support » feature

I would also like to request this feature, as it would help to control how the points are displayed.

kbahey’s picture

Userpoints cannot do views at the moment.

However, if someone writes a userpoints.inc that does that integration, I will be happy to include it.

BarisW’s picture

Component: Miscellaneous » Code: userpoints

Any updates yet? I'd like to have this too..

d0t101101’s picture

Version: 5.x-2.10 » 5.x-2.14

bump

funana’s picture

+1 :)

jredding’s picture

Please comment with a description of what you would like to see in views from the userpoints module. How would you use userpoints with views?

funana’s picture

e.g. I would create views for categories, sorted items by userpoints, add RSS to this views.

jredding’s picture

I'm not sure I understand this. What do you mean by categories, points don't have categories. Would you be trying to link points earned by node categories? or just display a listing of points per user?

ShutterFreak’s picture

Subscribing to this interesting feature request.

I would love to be able to display the number of points for a given user in a View, and to make that column sortable.

In addition, a Views filter could be implemented with a configurable minimum/maximum/exact number of user points.

funana’s picture

- Create a view for category pages
- Display the article teasers in this view sorted by the number of User Points the articles have

Views is so powerful. I was really suprised that user points didnt show up in views ;-)
There are thousands of options that could be realized via User Points / Views...

funana’s picture

Forget my posts here, sorry for confusion, but I simply mixed up userpoint with an other module. But anyway *g views support is a nice thing!
Sorry once again.

ebeyrent’s picture

I've started work on exposing Userpoints to Views, and can create a view listing users and their points. My next step is to add some filters so that I can list users and the points they accumulated per month.

I'm having some difficulty pulling in the data from the userpoints_txn table, so anyone with suggestions are welcome to assist...

jredding’s picture

If you're working on integrating views into userpoints please post your patch here and ask any questions you have. I'm currently working on a version 3 of userpoints and if you're code is pretty solid maybe we can integrate it in? or at least make it a contrib module.

Ask your questions here or contact me via the contact page. I'll help point you in the right direction the best I can.

kbahey’s picture

For those wanting to write patches for views integration ...

The issue is that views is node centric, whereas userpoints is user centric. Hence, we need a glue module to represent users as nodes, then build upon this module and extract data from userpoints and display it.

I did a similar thing for the fee module, using the bio module (the simplest of the users as nodes set of modules, the others being nodeprofile and usernode). Once each user is represented by a node, views have no problem displaying lists of users, and you can then write code to extract the current number of points, and have them sorted, ...etc.

See the fee module source for more details. The views functions are all at the end of the file.

ebeyrent’s picture

I used the Usernode and Nodeprofile modules and other related modules (http://shellmultimedia.com/node/274) to create user profiles as nodes. This method gave me more flexibility than the Bio module.

hedac’s picture

it should have to be a sort criteria entry like Node: Author Name
but Node: Author points

I think it is possible.. but still don't know how to program in drupal... or how API works...

thatashok’s picture

+1 for userpoints in views (fields, filters, and/or arguments)

webchick’s picture

Title: Views in userpoints » GHOP #62: Views in userpoints
thatashok’s picture

That's exciting! I'll be sure to check in the 3 - 5 days estimated time.

webchick’s picture

Well, no one has claimed it yet, but keep your eyes peeled. :)

MikeMoirano’s picture

Excellent! I would love to see this as well. Keep up the good work

mpaler’s picture

subscribing

atta_svg’s picture

I've been doing this with usernodes for a while now. Works great. Should be fairly simple to do with users as well, but I was already using usernodes.

Limitations: Filter will only work on users that has received points, as the rest will (in the DB) have NULL and not 0 points. If you just want to filter on >0, or >= 100, etc, then it will work fine.

Atle
ps! Remember to clear the views-cache if patching an existing module.
---

  $tables['usernode_points'] = array(
    'name' => 'userpoints',
    'provider' => 'userpoints',
    'join' => array(
      'type' => 'left',
      'left' => array(
        'table' => 'node',
        'field' => 'uid'
      ),
      'right' => array(
        'field' => 'uid'
      ),
    ),
    'fields' => array(
      'points' => array(
        'name' => t('Usernode: Points'),
        'sortable' => true,
        'help' => t('This will display the users points.'),
      ),
    ),
    'filters' => array(
        'points' => array(
          'name' => t('Usernode: Points'),
          'value-type' => 'integer',
          'operator' => 'views_handler_operator_gtlt',
          'help' => t('Filter users based on points.'),
      ),
    ),
    'sorts' => array(
      'points' => array(
        'name' => t('Usernode: Points'),
        'help' => t('This allows you to sort by user points.'),
      ),
    ),
  );
ebeyrent’s picture

StatusFileSize
new3.38 KB

I wrote a module to help with this - it may be a little rough, but might help some people out. Perhaps there can be some integration with atta_svg's work.

corsix’s picture

Status: Active » Needs review

Added views fields for node/comment author's points, and transactions. This allows you to do things like:

And if a module which links nodes to users is installed (I'm using usernode), then more things are possible:

The .inc file, as that is what the GHOP task wants as a deliverable:
http://www.corsix.org/drupal53/modules/views/modules/views_userpoints.in...
(this isn't a patch, but that status seems most appropriate)

mpaler’s picture

where to put this include file?

corsix’s picture

drupal/modules/views/modules/, as in the URL.

mpaler’s picture

works like a charm. Thanks!

kbahey’s picture

corsix,

I think this is a great addition to userpoints. I did not test it yet, but have a few questions.

- Why should this be under the views module? It should be under the userpoints module directory, so those who have userpoints commit access can maintain it. This is not the case if it is under the views module.

- I see that this is for the 2.14 version. Did you test it with the new and improved 3.x API? There are lots of changes and enhancements in that version.

- Can you compare what you did with what ebeyrent and atta_svg comments above, and see if they have anything that you missed, and merge them in?

Once the above is done, we can commit the combined work to the repository, and release a new version that has views integration in the official tar ball.

corsix’s picture

I can address the first point now, while I look into the other two.

The GHOP task asks for a .inc, and the conclusion from IRC (#drupal-ghop, December 20th 5:45 GMT) was a .inc for views:

<Corsix> jredding: What should userpoints_views.inc be? A inc for drupal53\modules\views\modules, something included by userpoints.module, or a new item in drupal53\modules\userpoints\contrib?
<jredding> Corsix: in the current implementation it would contributed module. 
<jredding> there is no .inc files for userpoints at the moment. 
<jredding> s/is/are 
<jredding> oh wait..
<jredding> read the post wrong..
<jredding> hhhm.. interesting.. 
<jredding> I'd say lets start from the userpoints side.. 
<jredding> as we can directly influence that..
<Corsix> so a new module for userpoints\contrib
<jredding> and it heavily depends on userpoints being there.. 
<jredding> ya.. userpoints/contrib 
<jredding> if it becomes extremely widely popular then it should be moved over to views.. 
<jredding> but until then.. we'll keep userpoints all together. 
<Corsix> So the deliverable will be a .info and a .module rather than a .inc
<jredding> yes. 
<jredding> does the task currently say .inc? 
<Corsix> This task is complete when a patch is posted to
<Corsix> http://drupal.org/node/120318 that has been reviewed by the community and
<Corsix> is marked "Ready to be committed"
<Corsix> Deliverables
<Corsix> *A userpoints_views.inc that does Views integration.
<Druplicon> http://drupal.org/node/120318 => GHOP #62: Views in userpoints => User Points, Code: userpoints, normal, active, 1 IRC mention
<jredding> hhhm.. I wonder why they wanted this to come from the views side.. 
<jredding> I mean I guess that where it makes the most sense.. but I submitted the task and I don't influence views..
<jredding> so I wouldn't be able to guarantee that it'd make it into the views module..
<jredding> it'd be easier for you to make a .inc file though..
<jredding> it'd reduce a tiny bit of coding.. 
<jredding> eh.. f* it.. make a .inc file for views. then we'll make sure it gets there if people want it there otherwise we'll rework it into a userpoints module.. 
<jredding> so.. 
<jredding> sorry to go back n' forth on you
<Corsix> its ok
<jredding> yes.. follow the task.
<jredding> make a .inc file for views. 
<jredding> we'll figure it out from there.. 

I can change it to be something for userpoints\contrib, as everyone seems to agree on that being the best place, provided that doing so still completes the task.

kbahey’s picture

It is definitely much better as something under contributions/modules/userpoints. Preferrably as an .inc file that we change userpoints to include_once if we detect views module as enabled.

Go ahead and merge any other worthy changes you see fit from the other two comments pointed to in my previous comments.

Once you are done with the 2.14 integartion, we can close the task with GHOP, then you can start working on the 3.x part.

jredding’s picture

I'll just chime in here just to verify that the above conversation was actually me ;) . A .inc file is easier to create as documentation already exists. Because this was a GHOP task and it was already challenging to begin with (Corsix is the 3rd person to claim it but around the 5th person to ask about the difficultly of it) I decided that a .inc file was simply easier to do.

The differences are subtle but I didn't want to cloud the GHOP task any further.

hopefully that clears up #1

as for #2
Corsix, I apologize. I didn't state this in the GHOP task and you did what you should have done; which is to use the stable version of the module. I submitted a few other userpoints tasks and on those I stated version 3 vs. version 2.14.
Without testing the code it should however work just fine against version 3 as those fields haven't changed. The .inc file could, however, be extended such as instead of joining on the uid you instead join on the node id and or comment id field as those are now available in version 3 via entity_id and entity_type. This, however, could be a bit confusing as entity_id and entity_type are not allows a node or a comment it is dependent on what is in entity_type.

Corsix I thought you tested against 3?

as for #3
"comparing with previous work". This is a excellent suggestion especially from a programming standpoint.

Going back to the .inc vs. contrib. The task didn't state it thus I see the task as complete as is.

It would be nice to roll it into a contrib module but as I told Corsix before we (which meant I ;) ) would be willing to take that on after the task was completed.

Corsix I'll let you make the final call as to if you would like to roll this into a contrib and/or do the suggestions above. You've done an excellent job on this task. In fact I would say you outdid yourself on this task. Not only did you take on one of the hardest tasks but you completed the task very quickly, with little help AND participated in the project's issue queue. You get a big applause from me.

Good job!

corsix’s picture

The top of this issue has:

Project:	User Points
Version:	5.x-2.14

Hence I developed and tested against version 2.14. I'll setup a fresh Drupal install and put v3 on there and see if anything breaks.

jredding’s picture

yes.. this is our fault. You did everything correctly Corsix. The task is complete as stated and you did a kick-booty job on it.

Thanks again for all your hardwork. I appreciate you taking the time to get the work done for version 3 though, it is much appreciated.

I'll update the task on google.

corsix’s picture

StatusFileSize
new2.42 KB

Changed it be a contrib module for userpoints 3.x, and added some additional fields/filters so that it could mimic the pages that v3 provides (description, operation, status fields for transactions, category field and filter, link to user details pseudo-field). Also updated the two default views to be views equivalents of the userpoints and myuserpoints pages.

Includes all the functionality from post #23.
#24 listed some interesting options for transactions in a specific month, but seemed to be incomplete, with function userpoints_views_views_points_query_handler being totally empty apart from comments, and function userpoints_views_views_points_query_handler_thismonth simply indexing a member function. As such, didn't integrate anything from post #24.

jredding’s picture

wow.. you're awesome.. Let me jump over to google right now and close that task!

jredding’s picture

GHOP task closed! again awesome job Corsix!!

This particular task, on d.o, will be closed when the code is submitted into the repository for inclusion in the download.

kbahey’s picture

Component: Code: userpoints » Code: userpoints_views
Status: Needs review » Fixed

I committed the module to HEAD, and branched it to 5.x-2.x and 5.x-3.x.

Corsix, can you check with 3.x and see if it needs work there? File a new issue.

kbahey’s picture

Corsix

I committed the attachment in #35 to both 3.x and 2.x. Is that the way it should be, or is that for 3.x only? If so, where is the code specific to 2.x?

kbahey’s picture

Version: 5.x-2.14 » 5.x-2.15

I took the version in #25 (last link) and modularized it, and released a new version.

To all, please test if 5.x-2.15 does views integration correctly ...

MikeMoirano’s picture

Thanks for this new feature. When you say "integrates with views", does that mean that there is a way to theme the view for the page that all of the users userpoints are displayed, the main, default page that lists every user and their userpoints? I am looking for a way to add a header to the page and to reduce the number of users on the page so as to provide a buried page, instead of having all 400 users listed in the same list.

Thanks

kbahey’s picture

Please do not ask support question in threads that are marked fixed.

The easiest way to answer your question is to download the module and check the views feature in it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

radyaweb’s picture

To using full function of user points in views module, you have to install usernode module too.
http://drupal.org/project/usernode

With usernode module, there will be an additional userpoint views field to be used. It should making usernode as required module for userpoints views integration. Because user will confused when looking for userpoint fields in views form.