Hi all,
a rather long post (sorry about that), as I need some feedback before putting too much effort in it. Here goes:
I needed some extra functionality, so I implemented the extension 'default_invoice'. For a more scalable solution, I would like to make the field, which holds the template, customizable (it is now hard-coded customer_cf4).
That's why I proposed a different way to store settings. Justin's concept of different 'domains' should also be possible, resulting in a settings table, with a 'domain_id' field and also an 'extension_id' field. To implement system-wide defaults, domain_id=0 is reserved for exactly that. Similar, extension_id=0 refers to the core system (anything not in an extension).
It is rather cumbersome, however, to manage all this through the config.ini file, as the id fields need to match up.
That is why I implemented 'manage_extensions', an extension to -well- just do that. (one thing lead to another, as usual...)
This is done in 2 steps:
step 1: register an extension (in your domain). The page lists all extensions found in the table (=registered) and the extensions directory (= unregistered). The content of the file DESCRIPTION is showed as a description.
When you register an extension, the name, description, domain and enabled=false is entered in the table. You have the opportunity to adjust the description. The extension_id is an auto-increment.
step 2: is enabling the extension. Basically is justs toggles the 'enable' field of the extension (in your domain). More to that later in this post. This step is the same for disabling (as it just toggles)
In init.php, a few lines of code is appended, which uses the extension table to create the 'extensions' part of the '$config' object. This way nothing need to be changed in the processing of the extensions.
The (settings of) extensions are processed in order (using the extension_id which is auto_inc), so the order to enable extensions can be relevant (later settings will override previous ones).
A final step is unregistering the extension. Basically this will remove the entry from the extensions table. IT ALSO REMOVES ANY EXTENSION-SPECIFIC SETTINGS
That was easy to implement, and is already in place. It is also needed, as the 'id' field is an auto_inc, and will never repeat itself.
WARNING: disabling the extension 'manage_extensions' will remove all this, and make the management unaccessible. the code in init.php always looks at the extensions table, so config_ini will be ignored.
When enabling an extension, I would like to do one more step: configure extension-specific settings, if any.
I was thinking of a special module in that extension, eg. settings.php
If it exists, run it to set up any settings. For convenience, I also think a default 'settings.php' would be handy. The extension only supplies the names of the required settings, the optional settings and the default values (if any).
eg:
<?php<br />
$canhave = array('option1','option2');
$musthave = array('default_template');
$default_settings['default_template'] = 'customer_cf4';
?>
Obviously, enabling the extension is only possible if all required settings are configured.
Is this a good idea? Any suggestions, improvements?
Marcel
hey marcel
thanks again - great work!!!
re settings
- i normally put all that type of info for an extension into the init.php file for that extension
- all you have to do is add the file ./extensions/your-extension/include/init.php and put in the info there and it'll auto get picked you and included
even though settings.php has a better name - init.php does the same thing and already works fine
let me know your thoughts
note: mange extensions extension will be included in the normal Simple Invoices once i've reviewed it correctly and fine tuned the UI
cheers
justin
okay..... I did not realize there was an init.php for the extensions as well...
What I am thinking of, is a standards way of configuring settings for extensions, which can be overridden if necessary.
I think a bit more about it, and let you know.
About the UI:
If you disable the tab menu (I used that one to test if all works as expected), the "module=options&view=index" page is not available any more (it is not in the old menu's), and that is exactly the place to start when managing extensions.
And I used icons (mostly from famfam, although the yellow light-switch is not, and could be a bit clearer) to avoid language issues.
Marcel
thanks again marcel - great work!
by the time of the full release hopefully both tab_menu and manage_extensions will be included in the normal SI code
cheers
justin
It looks like you're new here. If you want to get involved, click one of these buttons!