TL;DR: I want Contribution Aggregate by Relationship to show more years in the past.

I'm using the report "Contribution Aggregate by Relationship" to produce a report with columns for giving by year. However, it doesn't go back as many years as I'd like. I found how to control how many years it goes forward ("custom" date class in Settings - Date Preferences), but the same date class doesn't affect how far it goes back (three previous years then a catch-all for years before that). Is there something else that controls this? I need it to go back about 10 years or so.


Answering my own question:

My fix was to edit a file in "all", which isn't ideal since it'll get overwritten when updating CiviCRM, but I can always re-apply it.

Edit file: sites/all/modules/civicrm/CRM/Report/Form/Contribute/History.php

Change Line 61 from $yearsInPast = 4; to $yearsInPast = 20;

  • 1
    What I usually do when I need to change a core report a bit. Is to create an extension into which copy&paste the code of the core report and change it to my needs. Also I would have changed the hardcoded variable into a filter option which could be set in the user interface. May 18 '18 at 6:48
  • 1
    As Jaap says, create an extension with a copy of the existing report then modify. The --copy option on civix generate:report makes it very easy to get started.
    – Aidan
    May 18 '18 at 7:17

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.