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) »
  • Managing data in extensions
Pages: [1]

Author Topic: Managing data in extensions  (Read 460 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Managing data in extensions
January 04, 2014, 02:27:03 pm
I have been consistently finding that the over-head of creating tables & pages for minor entity-specific settings has been painful. So, I have set up a new extension to manage them https://github.com/eileenmcnaughton/nz.co.fuzion.entitysetting/blob/master/README.md

You can see the api examples here

https://github.com/eileenmcnaughton/nz.co.fuzion.entitysetting/tree/master/api/v3/examples

This means that other extensions don't need to set up a table to store, for example, a new configurable event setting. Within limitations the entity setting will add the configuration fields to the form too. So, for example, this extension adds 2 new settings to a configuration page (alternate page for thank you page & relationship to create if the form is filled out on behalf of someone else (cid=0 in the url)) - it defines the settings

https://github.com/eileenmcnaughton/nz.co.fuzion.frontendpageoptions/blob/master/settings/nz.co.fuzion.frontendpageoptions.contribution_page.entity_setting.php

& they are added to the contribution page configuration & the extension only has to worry about an api call to retrieve them - https://github.com/eileenmcnaughton/nz.co.fuzion.frontendpageoptions/blob/master/frontendpageoptions.php#L146

There are draw-backs to this & they are mostly documented in the README. I don't think that providing this functionality via an extension is a good long-term approach.

BONUS - if you do work on coding or testing contribution or event pages setting them to redirect back to the start / your next page instead of the thank you page is a nice time-saver

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Managing data in extensions
January 05, 2014, 06:59:35 am
so with your system, you don't benefit from all the nice native validation at the sql level (ie. be sure that if you set up a list of options for a field, you won't be able to create a record with an invalid option...)?

ie. what's the benefit over using optionvalue/group? if it's for a single int/boolean?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Managing data in extensions
January 05, 2014, 12:10:19 pm
How would an option value store that? ie. if I want to add a field to an event that holds an extra string & it might be configured for 1 or 500 events with different strings? For event entity I could create a custom field that extends the event but I can't extend a contribution page, a relationship type or an action schedule - which are the other entities I have needed to extend.

If the field I am adding has options (like the relationship_type field) then I those are being validated by the api but no, not at the sql level. But, I would have to walk a long path to make those validate at the sql level
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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

This forum was archived on 2017-11-26.