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 CiviMail (Moderator: Piotr Szotkowski) »
  • token substitution -- nick_name preferred, but first_name as alternative
Pages: [1]

Author Topic: token substitution -- nick_name preferred, but first_name as alternative  (Read 2125 times)

Sean Madsen

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 5
  • CiviCRM implementer/developer
    • Bikes Not Bombs
  • CiviCRM version: 4.6
  • CMS version: Drupal 7
token substitution -- nick_name preferred, but first_name as alternative
March 17, 2010, 03:46:25 pm
I'd like to be able to send an email with a greeting like this:
"Hi {contact.nick_name|contact.first_name}"
and have CiviCRM use the contact's nickname if it exists or the first name if the nickname doesn't exists.

I have the vague memory of reading something somewhere that provided a way to do it, but I can't seem to figure it out. (I tried the above syntax, as well as a space instead of a pipe, and I didn't work.)

This page seems like the logical place for such documentation:
http://wiki.civicrm.org/confluence/display/CRMDOC/Mail-merge+Tokens+for+Contact+Data

Also, I came across this posting:
http://forum.civicrm.org/index.php/topic,12614.0.html
But it doesn't seem to do quite what I want, as both values in my case are dynamic.

I'd rather not have to comb through all contacts and set values like "addressee" etc for them.

Is there an easy way to use the nickname by default and the first name in the case that there is no nickname?

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: token substitution -- nick_name preferred, but first_name as alternative
March 17, 2010, 03:56:09 pm

you'll implement the dynamic nature in the hook and use the db to retrieve the alternate values rather than the static values as given in the example

if you do implement that hook, would be good to add that code as a comment so other folks can benefit. at some point, we'll make the token system more elaborate

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

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: token substitution -- nick_name preferred, but first_name as alternative
July 28, 2010, 10:34:33 pm
Hey Sean - did you manage to make any headway on the above?
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

photolimo

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.67
  • PHP version: 5.2.5
Re: token substitution -- nick_name preferred, but first_name as alternative
March 29, 2011, 01:19:11 pm
Any update on this topic? I am terribly interested in having CiviCRM use the contact's nick_name if it exists and the first_name if the nickname does not exist.

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: token substitution -- nick_name preferred, but first_name as alternative
March 29, 2011, 03:36:20 pm

Unfortunately not.

Would be great if you can help with it and submit a patch that does the needful

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

werner

  • I’m new here
  • *
  • Posts: 21
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 6
  • MySQL version: mySQL 5
  • PHP version: php5
Re: token substitution -- nick_name preferred, but first_name as alternative
April 13, 2011, 03:03:35 am
Why don't you use the smarty templates (if else...)

More on that @ civicrm.org/node/480

Perry

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
  • CiviCRM version: 4.4.0
  • CMS version: WordPress 3.7.1
  • MySQL version: 5.5.32
  • PHP version: 5.5.26
Re: token substitution -- nick_name preferred, but first_name as alternative
April 17, 2014, 08:45:53 pm
I wonder if this information is helpful in
resolving the difficulty? Look under the
Paragraph header: Some "OR" Logic.
« Last Edit: April 17, 2014, 08:48:51 pm by Perry »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • token substitution -- nick_name preferred, but first_name as alternative

This forum was archived on 2017-11-26.