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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Best way to set up a config?
Pages: [1]

Author Topic: Best way to set up a config?  (Read 1361 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Best way to set up a config?
February 03, 2013, 02:46:56 pm
Hi,

On some extensions, you might want to configure on a per site basis some values. for instance the id of the tag you want to do something with in your extension.

Where to store that?

1) request the user to add a $my-extension = array("tag_id"=>42 );
and die with an error message if not set? how to explain you need this setting?
con: you need to configure it both in your staging and prod site, copy paste manual operation

2) put it into a config.php file in the extension
con: it will be erased when upgrade

3) ???
Any suggestion to leverage better the config/setting system from civi?


-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Best way to set up a config?
February 04, 2013, 05:26:17 am
On #3, there is a hook_civicrm_alterSettingsFolders which allows modules/extensions to register settings. This could be turned into a "civix generate:setting".

But that's really only the data-layer -- it doesn't provide the UX for editing settings. There are a few options, and maybe we should figure out the best recommendation among them:

1) In the description/documentation for each extension, advise users to put settings in civicrm.settings.php using the global $civicrm_setting.

2) Advise extension authors to include a settings form. There is a base-class which I haven't used personally but looks pretty convenient -- one extends CRM_Admin_Form_Setting and declares $_settings, e.g.

https://fisheye2.atlassian.com/browse/CiviCRM/trunk/CRM/Admin/Form/Setting/Miscellaneous.php?hb=true

3) Recommend CiviConfigure to anyone using extensions (or possibly merge it into core):

http://civicrm.org/extensions/civiconfigure

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Best way to set up a config?
February 04, 2013, 11:58:54 pm
Quote from: totten on February 04, 2013, 05:26:17 am
On #3, there is a hook_civicrm_alterSettingsFolders which allows modules/extensions to register settings. This could be turned into a "civix generate:setting".

Is this 4.3? could you add it to the wiki?
http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference
Quote

But that's really only the data-layer -- it doesn't provide the UX for editing settings. There are a few options, and maybe we should figure out the best recommendation among them:

1) In the description/documentation for each extension, advise users to put settings in civicrm.settings.php using the global $civicrm_setting.


What is the benefit over slapping any global variable? namespace and keep it clean?

Quote
2) Advise extension authors to include a settings form. There is a base-class which I haven't used personally but looks pretty convenient -- one extends CRM_Admin_Form_Setting and declares $_settings, e.g.
https://fisheye2.atlassian.com/browse/CiviCRM/trunk/CRM/Admin/Form/Setting/Miscellaneous.php?hb=true


Nicolas if you try, could you let us know?

Quote

3) Recommend CiviConfigure to anyone using extensions (or possibly merge it into core):

http://civicrm.org/extensions/civiconfigure

Sounds an interesting option and probably the easiest for simple values. I my case wanted an associative array, so not that simple.

@eileen, is the setting api already dealing with array type?

I Might add a simple json formatting on civiconfigure?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Best way to set up a config?
February 05, 2013, 07:45:51 am
Quote from: xavier on February 04, 2013, 11:58:54 pm
Quote from: totten on February 04, 2013, 05:26:17 am
On #3, there is a hook_civicrm_alterSettingsFolders which allows modules/extensions to register settings. This could be turned into a "civix generate:setting".

Is this 4.3? could you add it to the wiki?
http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference

I'll take a pass at it.

Quote from: xavier on February 04, 2013, 11:58:54 pm
Quote

But that's really only the data-layer -- it doesn't provide the UX for editing settings. There are a few options, and maybe we should figure out the best recommendation among them:

1) In the description/documentation for each extension, advise users to put settings in civicrm.settings.php using the global $civicrm_setting.


What is the benefit over slapping any global variable? namespace and keep it clean?

The approach of "put it in a config file" seems like a short-term solution to me -- it can ship quickly with minimal development. But it's not ideal to require users to edit config files. One wants a web-based form for small deployments; and one wants a dev/stage/prod workflow for big deployments. If each extension has its own data-structure, then it'll be harder to get these benefits for all extensions. The ambition of the "settings" framework is to provide the features needed for settings on both small and large deployments. (Note, for example, there's another thread discussing an integration between Civi settings and Drupal "Features".)

Quote from: xavier on February 04, 2013, 11:58:54 pm
Quote
2) Advise extension authors to include a settings form. There is a base-class which I haven't used personally but looks pretty convenient -- one extends CRM_Admin_Form_Setting and declares $_settings, e.g.
https://fisheye2.atlassian.com/browse/CiviCRM/trunk/CRM/Admin/Form/Setting/Miscellaneous.php?hb=true


Nicolas if you try, could you let us know?

Ditto

Quote from: xavier on February 04, 2013, 11:58:54 pm

Quote
3) Recommend CiviConfigure to anyone using extensions (or possibly merge it into core):

http://civicrm.org/extensions/civiconfigure

Sounds an interesting option and probably the easiest for simple values. I my case wanted an associative array, so not that simple.

@eileen, is the setting api already dealing with array type?

I Might add a simple json formatting on civiconfigure?

Thinking aloud... Would a SQL table or an OptionGroup be appropriate?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Best way to set up a config?
February 05, 2013, 01:25:53 pm
Not sure the db road is going to be that easier to jump the dev-staging-prod gaps, rather the contrary.

Would it make sense to define a folder structure on where to store the config files (eg. settings/org.example.extension.php) that can be moved between install or stay different?

I will have to study more the setting infrastructure for civi see what could be re-used for an extension, but having to deal with optionvalues or a custom table to store a simple associative array that is mostly static feels a bit an overkill.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: Best way to set up a config?
February 05, 2013, 01:41:39 pm

D8 has spent a fair bit of time on configuration management to make things easier

we should definitely take a look at it and see the scope it covers and what we can reuse / build on

deepak will be doing this over the next week or so as part of his course work. I'm encouraging him to write a detailed blog post on this :)

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Best way to set up a config?
February 05, 2013, 03:57:19 pm
Cool,

I'm eagerly waiting for a "top 10 reasons to get excited by the new configuration management"

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Best way to set up a config?
February 07, 2013, 08:43:18 am
I've been pondering the default settings issue for a while and until something better arrives, I'm going down the db road. It's simple and it works for my needs. I suppose an XML settings file would be handy as well but for me the db is there and all I need to do is use it. Mind you, I'm only dealing with a few settings which are mostly bools.

Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Best way to set up a config?

This forum was archived on 2017-11-26.