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) »
  • Creating an admin settings form for an extension?
Pages: [1]

Author Topic: Creating an admin settings form for an extension?  (Read 779 times)

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Creating an admin settings form for an extension?
February 01, 2013, 09:53:27 am
One thing that is really easy with Drupal modules is creating a settings page with hook_menu and the form api. Settings can easily be stored and retrieved using variable_get and variable_set.
What is the basic overview of how I would go about doing the equivalent process for a CiviCRM extension? I learned a little about extensions but I'm still not clear on this essential part.
Any suggestions for extensions that I could look at that have settings pages other than the payment processors since I assume they use the built-in page?

Just saw this and I am going to check out this one: http://civicrm.org/extensions/civiconfigure but still want to put this question out there for suggestions.
« Last Edit: February 01, 2013, 12:29:52 pm by lolas »
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

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: Creating an admin settings form for an extension?
February 01, 2013, 11:01:55 am

Might be a good addition to civix

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

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: Creating an admin settings form for an extension?
February 01, 2013, 12:39:10 pm
I think that would be an amazing extension to civix. Unfortunately I have no clue how to add it. :(

It would also be really super nice if there was a nice simple global extensions config array we could add settings to. Something like:

Code: [Select]
$config = CRM_Core_Config::singleton();
$ext_config = &$config::getExtensionConfig();
$ext_config['my.fully.qualified.extname']['mysetting'][] = 'myval';
$config::saveExtensionConfig();

or

Code: [Select]
$config = CRM_Core_Config::singleton();
$my_ext_config = $config::getExtensionConfig('my.fully.qualified.extname');
$my_ext_config['mysetting'][] = 'myval';
$config::saveExtensionConfig('my.fully.qualified.extname', $my_ext_config);
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Creating an admin settings form for an extension?
February 01, 2013, 02:52:56 pm
I agree an extension is the way to go nowadays, but there was this page I put up a few years ago for an older version but is still being used in production on a 4.2 site so it still works:
http://wiki.civicrm.org/confluence/display/CRMDOC/Six+simple+steps+to+creating+a+settings+page+for+your+module+or+custom+forms

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Creating an admin settings form for an extension?
February 01, 2013, 02:58:01 pm
Hmm, actually somebody's added step 3 which I don't understand - you should just be able to use the custom templates/php dirs as described at the link in the prerequisites section.

EDIT: Oh I see, at the bottom of step 3 it exlains. So you have a choice: either use step 3 or omit it and use the regular civi custom dirs.
« Last Edit: February 01, 2013, 03:00:53 pm by demeritcowboy »

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: Creating an admin settings form for an extension?
March 18, 2013, 11:04:30 am
demeritcowboy: Somehow I lost track of the thread. I realized a while back that my notification settings for the forum replies were not on. So I forgot to say thanks.  Your example is helpful and I'll have to give it a try.
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Creating an admin settings form for an extension?

This forum was archived on 2017-11-26.