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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Hide count on custom data group tab when not multiple
Pages: [1]

Author Topic: Hide count on custom data group tab when not multiple  (Read 956 times)

bwaindwain

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 1
Hide count on custom data group tab when not multiple
March 02, 2010, 02:30:07 pm
When a custom data group is set to hold only one record the tab still displays a count of 1 and the delete button is shown beside the group name (see attached image). This seems odd because it gives the appearance of handling multiple records.

Here's my fix...

CRM/Contact/Page/View/Summary.php around line 301 change the foreach loop to
Code: [Select]
foreach ( $activeGroups as $group ) {
$id = "custom_{$group['id']}";
$isMultiple = CRM_Core_DAO::getFieldValue( 'CRM_Core_DAO_CustomGroup',$group['id'],'is_multiple' );
if($isMultiple) $count = CRM_Contact_BAO_Contact::getCountComponent( $id, $this->_contactId, $group['table_name'] );
else $count = -1;
$allTabs[] = array(
'id'     => $id,
'url'    => CRM_Utils_System::url( $group['path'], $group['query'] . "&snippet=1&selectedChild=$id"),
'title'  => $group['title'],
'weight' => $weight,
'count'  => $count
);
$weight += 10;
}

templates/CRM/Contact/Page/View/Summary.tpl line 34 change to
Code: [Select]
<li id="tab_{$tabValue.id}"><a href="{$tabValue.url}" title="{$tabValue.title}">{$tabValue.title}{if $tabValue.count neq -1}&nbsp;({$tabValue.count}){/if}</a></li>
templates/CRM/Contact/Page/View/CustomDataView.tpl line 53 add "and $is_multiple" to the if conditions
CRM/Custom/Form/CustomData.php after line 104 add
Code: [Select]
$this->assign('is_multiple',CRM_Core_DAO::getFieldValue( 'CRM_Core_DAO_CustomGroup',$this->_groupId,'is_multiple' ));
There's probably a more elegant way to do this but I'll post it anyway and see what happens. I'm using CiviCRM 3.1.2.
« Last Edit: March 02, 2010, 02:52:43 pm by bwaindwain »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Hide count on custom data group tab when not multiple
March 02, 2010, 05:35:26 pm
The intent of the '1' in the tab is to indicate that some data has been recorded for this set of custom fields. The 'x' provides a way to clear all the field values in that set.
Protect your investment in CiviCRM by  becoming a Member!

bwaindwain

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 1
Re: Hide count on custom data group tab when not multiple
March 03, 2010, 07:57:41 am
Yes, I understand, but I still think this is non-standard behavior. There is no "(0)" beside "Demographics" and it doesn't change to "(1)" when you fill in their birthday. There is no delete button to wipe out all of the fields of "Communication Preferences"... etc.

Anyway, I've learned my lesson. Next time I won't spend time coding a solution until I get the thumbs-up from the CiviCRM admins.


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: Hide count on custom data group tab when not multiple
March 03, 2010, 08:08:26 am

hey bwaindwain:

i dont think we meant to be discouraging and we'd like you to continue exploring the code and submitting patches.

in the below case, you do raise valid points and we are not consistent in all places. Dave was just giving you our reasoning and thinking about it. If you still think we should fix this, jump on IRC and we can chat about it

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Hide count on custom data group tab when not multiple

This forum was archived on 2017-11-26.