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) »
  • Smarty to see if a string is contained in another string
Pages: [1]

Author Topic: Smarty to see if a string is contained in another string  (Read 8931 times)

questions

  • I post occasionally
  • **
  • Posts: 79
  • Karma: 2
  • CiviCRM version: 4.4.6
  • CMS version: Durpal, 7
  • MySQL version: 5.1
  • PHP version: 5.3
Smarty to see if a string is contained in another string
September 16, 2013, 11:05:40 am
Hi,

I've got some custom tokens that I'm using within CiviMail.  I'd like to see if a substring is in the token.

I googled smarty if string contains and find a couple of different methods.  Unfortunately, they all fail with some variation of "Call to undefined function"

The things I tried were:

{if strpos("{custom_token_name}", "PC") !== false}  bla bla bla {/if}

{if "{custom_token_name}"|strstr:"PC"}  bla bla bla {/if}

Short of creating a bunch more custom tokens that have just the substring, is there way?

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: Smarty to see if a string is contained in another string
September 16, 2013, 12:17:48 pm

have you enabled smary processing (in civicrm.settings.php) for your civimail? note that by default this is turned off (its a fair bit of overhead and creates a file per mailing)

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

questions

  • I post occasionally
  • **
  • Posts: 79
  • Karma: 2
  • CiviCRM version: 4.4.6
  • CMS version: Durpal, 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Smarty to see if a string is contained in another string
September 16, 2013, 02:16:55 pm
Yup, I have enabled smarty.  It was one of the things I doubled checked. 

I have other smarty logic in the mailing, mainly {if "{token_value}" neq ""}

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Smarty to see if a string is contained in another string

This forum was archived on 2017-11-26.