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) »
  • Where do you store variables?
Pages: [1]

Author Topic: Where do you store variables?  (Read 325 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)
Where do you store variables?
February 18, 2015, 08:47:15 am
Drupal has a nice variables tables, but CiviCRM doesn't.

For a number of years we've been using the the option_group and option_value table to store variables for our extensions, even though this isn't exactly what they were for. The nice part was that it allowed us to avoid programming an admin interface to allow system administrators to edit the fields occasionally. We have created a more user friendly interface for a few variables as well.

We've been disappointed that in 4.5 the values for option_values are no longer editable through the user interface (http://forum.civicrm.org/index.php/topic,35775.0.html). It seem we should either create a name field like the pattern for other fields in the schema that have machine names, or just revert the removal of edit-ability for the value field in these key-value pairs. Or perhaps create a variable table, or shove them into some serialized blob in a table like settings (not my preference).

So my question is: where do extension developers persist their variables? And should there be a default UI provided so that CiviCRM Admins can edit them easily without having to use a tool like phpMyAdmin that may not be available on some installations?
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Where do you store variables?
February 18, 2015, 09:01:05 am
Have you considered the settings system?

http://wiki.civicrm.org/confluence/display/CRMDOC/Settings+Reference

The wiki page links to an example from one of Eileen's extensions.

Compared to variables in D7, a setting takes more work (i.e. create the *.setting.php file) but also provides more value (i.e. typing, validation, defaults, more APIs, autowiring HTML widgets, self-documentation, and support in https://civicrm.org/extensions/civiconfigure ).

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)
Re: Where do you store variables?
February 19, 2015, 09:09:30 am
What do you think of adding an is_active field to https://github.com/civicrm/civicrm-core/blob/master/xml/schema/Core/Setting.xml so that Settings can be controlled via http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed ?
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Where do you store variables?

This forum was archived on 2017-11-26.