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) »
  • Smarty message template variable naming for component object fields
Pages: [1]

Author Topic: Smarty message template variable naming for component object fields  (Read 6560 times)

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Smarty message template variable naming for component object fields
July 15, 2013, 09:11:46 am
I'm trying to figure out if there is a pattern to how the Smarty variables in the component message templates are named (eg Memberships - Receipt (on-line)). Some are camelCase versions of db field names ($lineItem), some are the field names ($is_pay_later for civicrm_participant.is_pay_later), some are custom made up ($mem_end_date for civicrm_membership.end_date, $membership_name for label of civicrm_membership.membership_type_id - though I think it is called $title in the subject line, $isOnWaitlist for (non-standard name for a boolean field) civicrm_participant.must_wait (booleans are supposed to start with is_)).

I like the clarity of references like $line_item.description and $line_item.qty. Is there a problem if we exposed $grant with field names as keys? This seems cleaner.

The only additional point would be that we would add a translation of pseudo-FK id's into label values before the variable is assigned to Smarty so that this work would not be done by a callback from browser.  For example if we have a grant status, reason for grant rejection, etc., I was thinking it might be nice to create $grant.grant_status as the label as well as $grant.grant_status_id, and $grant.grant_reason_rejected as well as $grant.grant_reason_rejected_id. I'd prefer this to $grantStatus or $grant_status.

Comments and feedback?
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Smarty message template variable naming for component object fields
July 15, 2013, 10:29:28 am
I did a lot of work on pseudoconstant retrieval in 4.4. Having a method that automatically translates all labels from a given object would be the next logical step (and quite easy now that the groundwork is laid).
Try asking your question on the new CiviCRM help site.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Smarty message template variable naming for component object fields
July 15, 2013, 12:25:37 pm
See https://github.com/civicrm/civicrm-core/pull/1167
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Smarty message template variable naming for component object fields

This forum was archived on 2017-11-26.