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) »
  • Customising CRM_Contribute_Selector_Search output
Pages: [1]

Author Topic: Customising CRM_Contribute_Selector_Search output  (Read 1153 times)

artfulrobot.com

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 4
Customising CRM_Contribute_Selector_Search output
January 06, 2012, 05:27:04 am
Hi

I'm trying to remove the "Premium" column in Contribution results (CiviCRM 3.4.5) and replace it with Payment Instrument.

Data-wise, I've achieved this. The results now come with a column including Check, Direct Debit, etc. But I can't rename the column header, which seems to be something to do with sort fields.

In the $_columnHeaders array, I removed the sub-array for product (premium), and stuck one in saying Instrument. But this will only show up if I set the array's 'sort' key to 'product_name' - even though this is no longer in the results.

I assumed that 'sort' should now be instrument_id (the field that I added into $_properties), but this just hides the column header. I also tried 'instrument' (the field in the output, generated in the while (results->fetch) add to $rows loop) but again, it just causes it to vanish.

Thanks!

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: Customising CRM_Contribute_Selector_Search output
January 06, 2012, 11:16:21 am

how are you doing this?

can u check:

http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmsearchColumns

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Customising CRM_Contribute_Selector_Search output
January 06, 2012, 06:57:54 pm
As an aside payment instrument would probably be a better default than premium
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

artfulrobot.com

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 4
Re: Customising CRM_Contribute_Selector_Search output
January 09, 2012, 09:20:24 am
Quote from: Donald Lobo on January 06, 2012, 11:16:21 am
how are you doing this?

Hi Lobo, thanks for your support.

I can see that the hook would be a good way to add data, but I'm concerned about efficiency and sort-ability. As I can see (pls. tell me if I'm wrong!) bolting-on information in this way will not result in an orderable dataset, as the order is done before the hook call (and before paging)? I also need to add in various contribution custom field data...

To answer your question of how:

  • I added in "instrument_id" into the _columns array of  CRM_Contribute_Selector_Search. This gives the civicrm_contribute.payment_instrument_id in the initial results. My thought was that while this is a number, at least a sort on this field would still return the items grouped by type.
  • I then created a lookup array for all option values using CRM_Core_DAO_OptionValue for option_group_id = 10 (payment instrument on my install) and inside the while(results) loop I applied the lookup.
  • Changing the tpl then fills the column correctly.

Am I right about the hook and sort-ability?

cheers,

Rich

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: Customising CRM_Contribute_Selector_Search output
January 09, 2012, 11:48:53 am

hey rich:

its quite efficient (for most uses), since u can write one query for all the rows and get data that way. For super-large exports, i'm not sure what the behavior is, u'll need to use temp tables etc

u r right regarding sortability. BUT unless that is a deal killer, i would advocate using the hook rather than hacking core :)

Ping us on IRC and we can help u down the path of why your changes did not work etc (dont know offhand)

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

artfulrobot.com

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 4
Re: Customising CRM_Contribute_Selector_Search output
March 01, 2012, 09:29:59 am
Well, 2 months later I get to work on this again! (thx for IRC help in between posts. Not sure if updates to old posts get noticed...will find out soon!)

I've been trying to implement hook_civicrm_searchColumns() but it's not getting called?

My module is installed (other drupal hooks are being executed fine), but not this CiviCRM one. I'm expecting it to get called (at least) by looking at somone's contributions tab, or by a contributions search.

My hook code is not trying to do anything yet - I'm just calling error_log() to test whether it's being called.

I'm on 3.4.5.  I've cleared caches (drush cc all ; drush civicrm-cache-clear).

Any clues?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Customising CRM_Contribute_Selector_Search output

This forum was archived on 2017-11-26.