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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Getting object properties in hook_civicrm_alterContent
Pages: [1]

Author Topic: Getting object properties in hook_civicrm_alterContent  (Read 388 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Getting object properties in hook_civicrm_alterContent
April 17, 2014, 08:58:12 pm
I have an extension in which I implement the hook:      myextension_civicrm_alterContent()

I am checking when the value of $tplName = 'CRM/Price/Page/Field.tpl' , in which case I want to check which priceset they are editing. The $object parameter in this case is of type "CRM_Price_Page_Field".   This class has a protected property declared as " protected $_sid;

I need to check the value of the "_sid" so that my code can take appropriate action, but I cannot find a way to do this because the property is protected and their is no public function such as "getSid()".

How can I figure out the id of the priceset inside my "civicrm_alterContent" hook?
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Getting object properties in hook_civicrm_alterContent
April 18, 2014, 12:49:09 am
Can you not get it with $object->getVar('_sid')?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Getting object properties in hook_civicrm_alterContent
April 18, 2014, 08:22:03 am
Erik - The code  $object->getVar('_sid');  worked perfectly. Thanks for the tip.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Getting object properties in hook_civicrm_alterContent
April 18, 2014, 10:05:52 am
good luck!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Getting object properties in hook_civicrm_alterContent

This forum was archived on 2017-11-26.