2

I am creating a site where there are nodes (which are "causes") that users can donate to (i.e. buying a donation product using Drupal Commerce, which is sort of irrelevant, but just for the record).

I would like to display a "ranking" on each node based on how much money has been donated to that cause. It will be output something like "Rank: 50 out of 210".

My question is: What is the best way to do this?

I know how I could create a view and sort it by the criteria that I'm wanting, but then how to display on a node the index from the view... ? I don't know how to do that.

I've thought about figuring out a way to use Rules to assign a value to a field in the node whenever a donation is made... ? That might be a decent bet.

If anyone has any direction for me on this, I'd really appreciate it.

0

No need to make things that difficult; Views supports a field that display the sort index. It's labeled Global: View result counter.

Views Counter

It won't get you total results, but you can put that information in the header/footer with the Global: Result summary field.

Views Result Summary

| improve this answer | |
  • thank you for your response. I'm afraid that's not quite what I'm looking for. See, on the node page is where I need to display the result and what needs to be displayed is just the "RANK out of TOTAL" text. So, whatever the view (or whatever) outputs, I need to be able to use a contextual filter to show exactly one result with the rank and total numbers. – Rewdy May 21 '15 at 20:15
0

Ranking gave me some headaches too (user ranking). What I ended up doing was:

1) creating a Views VBO list (shows the ranking in the order I need), 2) sent it to Rules and load the list (load a list of entity ids from VBO action) 3) and loop through it. Within the loop I added an INT counter variable. This variable sets the value of the ranking field on the user profile. The counter is increased by 1 at the end of the loop.

The rule is executed on cron (so the changes in the ranking are only then visible). I just could not figure out a better way but it works for me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.