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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Is hook_civicrm_token implemented?
Pages: [1]

Author Topic: Is hook_civicrm_token implemented?  (Read 1978 times)

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Is hook_civicrm_token implemented?
August 16, 2009, 10:52:50 pm
I'm looking at some mods I'll need to do for CiviMail and related parts of 2.2.

It looks as if hook_civicrm_token and hook_civicrm_tokenValues do what I want, but as far as I can tell, the mail subsystems aren't actually invoking the hook; this is true of both 2.2 and the trunk.  Do I misunderstand how these hooks are intended to be used?  I'm guessing that they are supposed to do what the Drupal Tokens module does -- allow for text substitution in things like emails and such.

If the code in CRM/Utils/Hooks.php and CRM/Utils/Tokens.php can be used this way, I'd probably want to implement a call of these hooks to work with mailing templates.  Is this compatible with the intended use of these hooks?  And if so, is anyone else interested in seeing this implemented?

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Is hook_civicrm_token implemented?
August 17, 2009, 02:57:49 am
Quote
It looks as if hook_civicrm_token and hook_civicrm_tokenValues do what I want, but as far as I can tell, the mail subsystems aren't actually invoking the hook; this is true of both 2.2 and the trunk.

hooks are working fine for 'CiviMail' and 'Send Email to Contacts' / 'Send an Email' processes.

related issue is here : http://issues.civicrm.org/jira/browse/CRM-3712

you might want to read documentation : http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification

also might want to give more details about your use case.

hope this help

kiran
You Are Designed To Choose... Defined By Choice.

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: Is hook_civicrm_token implemented?
August 17, 2009, 04:37:38 pm
There are no examples in the hooks page for either of these hooks;  that would help a lot.

I've finally found where you're calling these.  For hook_civicrm_tokenValues,  in 2.2:

Code: [Select]
CRM/Mailing/BAO/Mailing.php:962:            CRM_Utils_Hook::tokenValues( $contact, $contactId );
CRM/Mailing/BAO/Mailing.php:1934:        CRM_Utils_Hook::tokenValues( $details[0], $contactIDs );
CRM/Contact/Form/Task/Label.php:206:        CRM_Utils_Hook::tokenValues( $details[0], $this->_contactIds );

This at least makes it clear what gets passed to them.  It also makes it possible for me to determine what needs to get tested


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: Is hook_civicrm_token implemented?
August 17, 2009, 04:48:58 pm

check

civitest.module.sample

most of the hook implementation in there are quite realistic :)

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

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: Is hook_civicrm_token implemented?
August 17, 2009, 05:05:50 pm
Found it, finally.

I've updated the Hooks wiki page so that the samples are readily findable.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Is hook_civicrm_token implemented?

This forum was archived on 2017-11-26.