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 »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • smartgroups based on age
Pages: [1]

Author Topic: smartgroups based on age  (Read 1358 times)

mudnik

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: drupal
  • MySQL version: 5.5.34-cll
  • PHP version: 5.4.23
smartgroups based on age
December 15, 2013, 01:31:10 am
How do I create a smart group based on age? eg everyone below 21 years old.

I currently have a Date of birth field, but creating a search based on that doesn't work as the people with age less than 21 is going to be based on a different DOB every year.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: smartgroups based on age
December 15, 2013, 10:26:01 am

You will need to write a custom search extension for this. If you do so, please share your extension so others can benefit.

You'll need some civi/php/mysql knowledge to implement this. Should be quite a useful extension

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: smartgroups based on age
December 15, 2013, 02:23:07 pm
2 other customizations that might be even more useful to contribute back:

1) Add "age" as a param in advanced search (basically a calculated field)
2) (more generalized) Add relative date filters to search builder.

As above this would all require some coding experience, but would be of great benefit to the community.
Try asking your question on the new CiviCRM help site.

mudnik

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: drupal
  • MySQL version: 5.5.34-cll
  • PHP version: 5.4.23
Re: smartgroups based on age
December 15, 2013, 06:03:22 pm
Is it based on the instructions here?

http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Custom-Search+Extension

http://book.civicrm.org/developer/version/4.1/the-extensions-framework/custom-searches

https://civicrm.org/blogs/michal/civicrm-extensions-framework-packaging-your-custom-search

Unfortunately, I have limited coding experience, so this is gonna take a while...

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: smartgroups based on age
December 15, 2013, 08:07:41 pm
Yes. CRMDOC is the most up-to-date but the others are probably useful too.
Try asking your question on the new CiviCRM help site.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: smartgroups based on age
December 15, 2013, 10:17:58 pm
dare i ask what the purpose of the group is ... i e what are you going to do 'with' the group once you make it, in case there is another option
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

mudnik

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: drupal
  • MySQL version: 5.5.34-cll
  • PHP version: 5.4.23
Re: smartgroups based on age
December 16, 2013, 05:13:34 am
Hi Petednz,

My members span a wide range of ages, from the young to the old.

Inside my club, we have events targeted at the various age groups.

There's a under 12 year old group, as well as a youth group, among others.

We call them sub-groups.

The purpose of identifying these people is for us to send out emails only to the group.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: smartgroups based on age
December 16, 2013, 06:39:10 am

if your org/client has the funding, consider hiring someone from our providers listing to develop and contribute this back. Will make it a lot easier for you and also benefit the larger community

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FrTommy

  • I post frequently
  • ***
  • Posts: 273
  • Karma: 2
  • CiviCRM version: 4.5.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5.32
  • PHP version: 5.3
Re: smartgroups based on age
May 07, 2014, 06:51:42 pm
I'm looking for a custom search so I can create smart groups as well based on age and gender. I found this on the CRMDOC site:https://wiki.civicrm.org/confluence/display/CRMDOC/Search+on+Gender+and+Age   however it gives the error:


Fatal error: Declaration of CRM_Contact_Form_Search_Custom_AgeGenderListing::all() must be compatible with that of CRM_Contact_Form_Search_Interface::all() in /mysite/CRM/Contact/Form/Search/Custom/AgeGenderListing.php on line 38

I've compared the AgeGenderListing.php with a newer custom search and could not figure out why it was giving the error. I made some changes but couldn't figure it out. Anyone happen to have this working?

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: smartgroups based on age
May 09, 2014, 03:10:44 am
Looks like that search code is not updated to the latest Civi.  Try changing line 98 from this:
 
Code: [Select]
                 $includeContactIDs = false ) {to this:
 
Code: [Select]
                 $includeContactIDs = false, $justIDs = false ) {

FrTommy

  • I post frequently
  • ***
  • Posts: 273
  • Karma: 2
  • CiviCRM version: 4.5.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5.32
  • PHP version: 5.3
Re: smartgroups based on age
May 09, 2014, 09:41:33 am
That created a new error on line 74. I figured that one out by looking at another search. I had to update the gender code to use the new way of referring to a Psuedoconstant.
Replace this:
Code: [Select]
        $gender = array('' => ts('- any gender -')) + CRM_Core_PseudoConstant::gender( );
        foreach ($gender as $key => $var) {
                $genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
            }

With this starting on line 74
Code: [Select]
    $genderOptions = array();
    $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
    foreach ($gender as $key => $var) {
      $genderOptions[$key] = $form->createElement('radio', NULL,
        ts('Gender'), $var, $key,
        array('id' => "civicrm_gender_{$var}_{$key}")
      );
    }

I updated the CRMDOC with the changes.
« Last Edit: May 09, 2014, 09:45:50 am by FrTommy »

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: smartgroups based on age
June 17, 2014, 11:41:23 am
I was wondering if you ever created the search based on age extension / custom search?

mudnik

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: drupal
  • MySQL version: 5.5.34-cll
  • PHP version: 5.4.23
Re: smartgroups based on age
November 02, 2014, 09:24:09 pm
No, I didn't.

I change the smart groups criteria every year.

Quote from: sonicthoughts on June 17, 2014, 11:41:23 am
I was wondering if you ever created the search based on age extension / custom search?

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: smartgroups based on age
November 03, 2014, 08:47:43 am
I wonder how many years will pass before it would have saved you time to write the code ;D
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

mudnik

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: drupal
  • MySQL version: 5.5.34-cll
  • PHP version: 5.4.23
Re: smartgroups based on age
November 13, 2014, 12:11:11 am
The problem is, I'm not programmer.  ??? Will also need to invest time to learn the coding.  :P

Quote from: Michael McAndrew on November 03, 2014, 08:47:43 am
I wonder how many years will pass before it would have saved you time to write the code ;D

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • smartgroups based on age

This forum was archived on 2017-11-26.