CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Way to display the total number of contacts in the Manage Groups Table?
Pages: [1]

Author Topic: Way to display the total number of contacts in the Manage Groups Table?  (Read 1280 times)

maiasiber

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
Way to display the total number of contacts in the Manage Groups Table?
October 10, 2008, 08:35:00 am
Hello,

I need to be able to display the total number of contacts within each group on the Manage Groups Table (Rather than the group ID #).  Does anyone know the code to do this?  Any help would be greatly appreciated!!!

Maia Siber

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Way to display the total number of contacts in the Manage Groups Table?
October 10, 2008, 09:21:31 am
Quote
SELECT count(DISTINCT contact_a.id)  FROM civicrm_contact contact_a  LEFT JOIN civicrm_group_contact ON contact_a.id = civicrm_group_contact.contact_id   WHERE  ( civicrm_group_contact.group_id IN ( 3 ) AND civicrm_group_contact.status IN ("Added") )     

This query should be able to give you count of contacts per group (above eg with gid =3)

Kurund
Found this reply helpful? Support CiviCRM

maiasiber

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
Re: Way to display the total number of contacts in the Manage Groups Table?
October 10, 2008, 10:59:46 am
Kurund, thank you for your quick response.. Your query works in the MySQL, but I'm having difficulty putting it in the Group.php file... Here's what I put in after the "visibility" column (named my totals column "members"):

$values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
$values[$object->id]['members'] = SELECT count(DISTINCT contact_a.id) FROM civicrm_contact contact_a LEFT JOIN civicrm_group_contact ON contact_a.id = civicrm_group_contact.contact_id WHERE ( civicrm_group_contact.group_id IN ( $object->id ) AND civicrm_group_contact.status IN ('Added') );

I get an error that says "Parse error: syntax error, unexpected T_STRING in .../CRM/sites/all/modules/civicrm/CRM/Group/Page/Group.php on line 267".

Do you know what the proper syntax is?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Way to display the total number of contacts in the Manage Groups Table?
October 10, 2008, 12:44:48 pm
You need to fire SQL separately for each group and then assign return values to array elements. Please read php manual : http://us3.php.net/manual/en/index.php

HTH

Kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Way to display the total number of contacts in the Manage Groups Table?

This forum was archived on 2017-11-26.