Front end Stats extension for CiviCRM

Published
2012-10-26 17:37
Written by
ChrisChinchilla - member of the CiviCRM community - view blog guidelines

 

I've been tinkering with this for a while and now have a limited extension released for easily displaying statistics about your constituents in front end locations of your website using CiviCRM Smarty tokens.

There's only a few available right now, mainly due to my own time constraints, but also because I'd like people to tell me what they need and I'll add functionality that way.

Firstly, download the 'CiviStats' extension here. As you can see from the instructions, there are a couple of stats you can currently pull out, generally you need to use the CiviCRM API call first and then you have the various variables available to you, all of these can be done on pages, blocks, themes etc… But you will need to have Smarty tags being parsed in your Input filter (sorry, I'm a Drupal developer, no idea how you do this in Wordpress or Joomla), in time, I'll get some better instructions for this!

This is all rather vague now, but I'd like some feedback on what people need/don't understand.

 

All contributions and how many

Initial API call - {crmAPI var="StatsS" entity="Stats" action="totalcontributions" sequential="1" }

Amount: {$StatsS.total|crmMoney} (the money formatter is optional, but exceptionally helpful and will localise the output to)

Count: {$StatsS.count}

 

Yearly contributions and how many

Initial API call - {crmAPI var="StatsS" entity="Stats" action="yearlycontributions" sequential="1" }

Amount: {$StatsS.total|crmMoney}

Count: {$StatsS.count}

 

Number of members

{crmAPI var="StatsS" entity="Stats" action="current" sequential="1" }

{$StatsS}

(This will only pull in members that have been defined by you as 'current', 'new', 'grace', so active ones)

 

Filed under

Comments

Hi,

I think we discussed it a long while ago and that one "more api" solution was to have the stat as an action on the entity rather than the other way around.

SO instead of

{crmAPI var="StatsS" entity="Stats" action="yearlycontributions" sequential="1" }

have {crmAPI var="StatsS" entity="contribution" action="getstats" name="yearly" sequential="1" }

clearer example: this one doesn't describe what it does

{crmAPI var="StatsS" entity="Stats" action="current" sequential="1" }

this one is hopefully clearer
{crmAPI var="StatsS" entity="member" action="getstats" name="current" sequential="1" }
 

 

I don't recall what was the reasoning on keeping your initial syntax. Was this a technical issue?

Would this be able to go down to a contact level?

Sum of X person's contributions which have the campaign of Y?