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) »
  • Getting state abbreviation and country name tokens in summary.tpl
Pages: [1]

Author Topic: Getting state abbreviation and country name tokens in summary.tpl  (Read 2817 times)

rosscarpenter

  • Guest
Getting state abbreviation and country name tokens in summary.tpl
November 18, 2009, 06:23:29 am
I am adding a hyper link from the contact view page that points to my clients main website. They want the name and address passed to them in a URL. I am editing summary.tpl where I have found out all the tokens I need except the state abbreviation and the country name. The tokens that I have found are state_province_id and country_id which both return what I assume is a primary key. Are there any tokens available that will return the state abbreviation and the country name or do I have to perform a database lookup?
Ross

Specifically the tokens I can find are as follows:
STATE: {$address.1.state_province_id}
COUNTRY: {$address.1.country_id}

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: Getting state abbreviation and country name tokens in summary.tpl
November 18, 2009, 06:51:51 am

you will need to perform a DB lookup for those values. They are not exposed to the template :(

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

rosscarpenter

  • Guest
Re: Getting state abbreviation and country name tokens in summary.tpl
November 19, 2009, 12:42:06 pm
Thanks, I was afraid of that. Any idea what the specific query string would be for this? I don't not have direct access to view the MySQL tables.....

Ros
« Last Edit: November 19, 2009, 12:44:36 pm by rosscarpenter »

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: Getting state abbreviation and country name tokens in summary.tpl
November 19, 2009, 08:18:14 pm

you can access the mysql tables directly (civicrm_country and civicrm_state_province)

The functions to access them programmatically are in CRM/Core/PseudoConstant.php

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

rosscarpenter

  • Guest
Re: Getting state abbreviation and country name tokens in summary.tpl
November 20, 2009, 06:03:52 am
Thank you! Exactly what I needed. ;D    I am a long time wordpress developer, newbie to Drupal and CivicRM

To summarize what I have learned:

The file 'CRM/Core/PseudoConstant.php' contains all sorts of info that is helpful to the CivicRM developer
The INC files located in 'drupal/modules/views/civicrm' contained everything I needed for my task at hand

To retrieve states and/or countries:

    require_once 'CRM/Core/PseudoConstant.php';
    $_states = CRM_Core_PseudoConstant::stateProvinceAbbreviation();  //optionally pass state_province_id to get a specific state
    $_countries = CRM_Core_PseudoConstant::country( );  //optionally pass country_id to get a specific country

-Ross
« Last Edit: November 20, 2009, 07:18:53 am by rosscarpenter »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Getting state abbreviation and country name tokens in summary.tpl

This forum was archived on 2017-11-26.