#72 Core Hack to allow config options categorisation

XOOPS_2.2
closed
5
2014-07-13
2004-11-02
No

Hi !

I'm currently developping SmartContent and I found out
that this module desperatly needs config options
categorisation. We are developping this module to be
really flexible. To do so, we need a lot of config
options. Categorisating them makes it easier for the
site admin.

So, I've hacked the core to be able to do what I
needed. I've packaged all this and you can download it
here :
[url=http://www.smartfactory.ca/configcat_hack.zip]configcat_hack.zip[/url]

[u][b]What is it ?[/b][/u]

This hack changes the way configuration options are
handled. It allows a module developper to group the
module config options in categories.

Of course, modules that do not use config categories
will work as usual, without categorisation.

[u][b]Installation[/b][/u]

  • Copy all the files of the zip file at the root of
    your site.
  • Point your browser to
    www.yoursite.com/config_upgrade.php. This will update
    the database as some new fields are required for this
    to work.

  • To actually see this hack in action, you will need to
    install a module that uses config categorisation. I've
    included in the package the module SmartContent that
    uses config category. Please note that this module is
    still in active developpement. Simply install it as any
    other module.

[u][b]How does it work[/b][/u]

In the xoops_version.php file of your module, you need
to create some config categories. Here is an example
from SmartContent :

[code]// Config categories
$modversion['configcat'][1]['nameid'] = 'global';
$modversion['configcat'][1]['name'] = '_MI_SC_CAT_GLOBAL';
$modversion['configcat'][1]['description'] =
'_MI_SC_CAT_GLOBAL_DSC';

$modversion['configcat'][2]['nameid'] = 'user_side';
$modversion['configcat'][2]['name'] =
'_MI_SC_CAT_USER_SIDE';
$modversion['configcat'][2]['description'] =
'_MI_SC_CAT_USER_SIDE_DSC';[/code]

Then, on each config option, you can add a line to say
in which category it belongs. If don't specify a
category, te option will simply be displayed in the
Other Options at the end of the preferences :

[code]$modversion['config'][1]['name'] = 'dateformat';
$modversion['config'][1]['title'] = '_MI_SC_DATEFORMAT';
$modversion['config'][1]['description'] =
'_MI_SC_DATEFORMATDSC';
$modversion['config'][1]['formtype'] = 'textbox';
$modversion['config'][1]['valuetype'] = 'text';
$modversion['config'][1]['default'] = 'd-M-Y H:i';
$modversion['config'][1]['category'] = 'global';[/code]

That's it !

Comment will be trully appreciated ! Is this something
that could be implemented in XOOPS ? Is there some side
effects I did not see ?

If this could be in 2.0.9... :-)

Cheers !

Discussion

  • Marc-Andre Lanciault

    Logged In: YES
    user_id=880332

    I've uploaded the package in this patche

     
  • Marc-Andre Lanciault

    Logged In: YES
    user_id=880332

    little fix :

    in modules/system/admin/modulesadmin/mian.php, line 598 has
    to be replaced by

    if (isset($config['category'])) {
    $confobj->setVar('conf_catnameid', $config['category']);
    }

     
  • Jan Pedersen

    Jan Pedersen - 2005-05-07

    Logged In: YES
    user_id=841117

    OK, I'll take care of this one personally.

     
  • Jan Pedersen

    Jan Pedersen - 2005-05-11

    Logged In: YES
    user_id=841117

    Implemented a solution based on this patch in 2.1 CVS

     

Log in to post a comment.