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 CiviEvent (Moderator: Yashodha Chaku) »
  • Contact tokens syntax
Pages: [1]

Author Topic: Contact tokens syntax  (Read 660 times)

ollea

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: 7.25
  • MySQL version: 5.5.22
  • PHP version: 5.3.10
Contact tokens syntax
February 15, 2013, 12:16:37 am
Hello,

I am sure that is something really easy but I have been trying for more than an hour without success to print the contact's address in an e-mail using tokens.

Here is what I added in the "Events - Subscription confirmation and receipt (offline)" :

Code: [Select]
       {if contact.custom_2}{contact.custom_2}<br/>{/if}
        {if contact.custom_3}{contact.custom_3}<br/>{/if}
        {contact.first_name} {contact.last_name|upper}<br/>
        {contact.street_address}<br/>
        {if contact.supplemental_address_1}{contact.supplemental_address_1}<br/>{/if}
        {if contact.supplemental_address_2}{contact.supplemental_address_2}<br/>{/if}
        {contact.postal_code} {contact.city}

But then there is a lot of smart errors and the last name is not printed at all (even in normal case).

I have red the smarty documentations, searched the forum but no chance...

Your help will be really appreciated,

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: Contact tokens syntax
February 15, 2013, 08:50:37 am

1. There is a difference between civicrm tokens and smarty tokens (bad design decision on our part a long long time ago)

2. Can you remove the |upper part of the last_name token and see if that fixes 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

ollea

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: 7.25
  • MySQL version: 5.5.22
  • PHP version: 5.3.10
Re: Contact tokens syntax
February 18, 2013, 06:18:22 am
Yes, without the "|upper" and "if" statements there is no error but is it possible to format the last name in upper case and adding "if" statements to check if a variable is empty or not ?

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: Contact tokens syntax
February 18, 2013, 10:06:55 am

check your civicrm.settings.php file, and fix this constant:

/**                                                                                                                             
 * Enable this constant, if you want to send your email through the smarty                                                       
 * templating engine(allows you to do conditional and more complex logic)                                                       
 *                                                                                                                               
 */
define( 'CIVICRM_MAIL_SMARTY', 0 );

I dont think modifiers like "|upper" will work, but conditionals should work

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

ollea

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: 7.25
  • MySQL version: 5.5.22
  • PHP version: 5.3.10
Re: Contact tokens syntax
February 19, 2013, 02:14:36 am
Thank you, it works better with Smarty enabled.
Here is the code in case of need by somebody else :

Code: [Select]
        {capture assign=institution}{contact.custom_2}{/capture}{if $institution}{$institution}<br/>{/if}
        {capture assign=complement_institution}{contact.custom_3}{/capture}{if $complement_institution}{$complement_institution}<br/>{/if}
        {contact.first_name} {capture assign=last_name}{contact.last_name}{/capture}{$last_name|upper}<br/>
        {contact.street_address}<br/>
        {capture assign=supplemental_address_1}{contact.supplemental_address_1}{/capture}{if $supplemental_address_1}{$supplemental_address_1}<br/>{/if}
        {capture assign=supplemental_address_2}{contact.supplemental_address_2}{/capture}{if $supplemental_address_2}{$supplemental_address_2}<br/>{/if}
        {contact.postal_code} {contact.city}

But I cannot print custom fields for event object, do you have any idea ?
I tried with "{event.custom_2}" and "{$event.custom_2}".

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: Contact tokens syntax
February 19, 2013, 08:25:54 am

We do not expose event custom fields (or other objects) via tokens as yet. You'll need to do this via hooks. Check the book / wiki / blog on how to create custom tokens

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) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Contact tokens syntax

This forum was archived on 2017-11-26.