2

I created a drupal view to display contributor names. The view displays civicrm fields, both custom fields I have created and out-of-the-box civicrm fields.

The contributors are displayed according to the amount of their contribution. For instance, there are "Gold" contributors at the top, then "Silver", then "Bronze" etc.

The categories that contributors should be displayed within is not related to the total amount of the contribution. So, for instance, I have a "Silver" contributor that gave more than a "Gold" contributor (for reasons related to an event).

The problem is how to sort the fields so that the "Gold" group displays higher up than the "Silver" group. I cannot use Total Amount (desc) because of this silly Silver contribution that was more than the Gold contribution.

I tried creating a custom field where these groups of contributions were simply assigned numbers, so Gold=1, Silver=2, Bronze=3, etc. When I use this criteria to sort, desc will put the Gold after Silver, so that it is highest in reverse order. But when I use asc, which should put Gold at the top, instead Gold is after Silver.

This is driving me nuts. I realize it's pretty convoluted, so it's possible no one will actually read to the end. But there has to be a way to do this.

2

I did read all the way down!

Try Adding a Global PHP field under Sort Criteria-> you can then use PHP to say -> Gold=1, Silver=2 and Bronze=3; And indicate you want to sort Ascending.

If you need a hand with the PHP - let me know.

  • Thanks, what you're saying make sense. I believe I need View PHP in order to do this ... but Views PHP is not covered by drupal's security advisory. Am I worrying too much? – LaurynnLowe Apr 7 '17 at 3:37
  • It can't apply to be covered until it has an official rc - see: drupal.org/node/1011698 - so it does not necessarily mean it's not secure. – KarinG - Semper IT Apr 7 '17 at 12:00
  • I will try and post if it works. – LaurynnLowe Apr 7 '17 at 14:48
  • Hey - did you get it working - if you need help w/ php bit let me know – KarinG - Semper IT Apr 9 '17 at 16:41
  • no, the donor with the "silver" contribution decided to donate even more money, so now they are in the "platinum" group and I can use a simple asc by total amount. --I'm a little disappointed; I was curious to try this solution out – LaurynnLowe Apr 10 '17 at 0:00
0

Not sure I fully understand what you are seeing, but are you meaning it is sorting as Bronze, Gold, Silver and Silver, Gold, Bronze? ie alphabetically on the label rather than on the value? If so, and if you don't care too much about the labels you could relabel them as '1 - Gold', '2 - Silver', '3 - Bronze'

  • I did have a label with "1 Gold", "2 Silver" and it still didn't work. I don't understand why. I thought perhaps because it was a civiCRM custom field? – LaurynnLowe Apr 9 '17 at 12:52
0

A simple work around would be to create three separate view blocks, one for each group, and then combine them in your favourite manner (e.g. context, block visibility, or the view field that pulls in other views, etc.)

Here's an example: https://casrai.org/reconnect16 (the sponsor blocks at the bottom of this page).

  • Yes! I absolutely considered this. Since there are 6 groups, hence 6 view blocks, I'm glad it didn't come to this. – LaurynnLowe Apr 13 '17 at 2:12

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.