How to access Module Parameters?

Hello everybody,
I am trying my luck with module development, I have my main functions working and am almost done. What is keeping me back is that I have no clue how I can access my modules parameters from the setup page. I have tried looking in different php files but have not been able to figure it out. It is probably very simple but maybe someone can point me in the right direction.

Hi,

It is in the module declaration, you declare what php script in the admin folder is the setup page :

// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
		$this->config_page_url = array("setup.php@mymodule");
1 Like

In v12 this is my implementation:

core/modules/modMyModule.class.php:

 $this->const = array(
			//0=>array	('MAIN_MODULE_LIMS_HOOKS', 'chaine', 'samplescard', 'Hooks list for managing printing functions', 0),
			1 => array('LIMS_PREFIX_SAMPLES', 'chaine', 'SA', 'Pre-fix for Sample objects', 1, 'allentities', 1),
			2 => array('LIMS_PREFIX_METHODS', 'chaine', 'ME', 'Pre-fix for Method objects', 1, 'allentities', 1),
			3 => array('LIMS_PREFIX_RESULTS', 'chaine', 'RE', 'Pre-fix for Result objects', 1, 'allentities', 1),
            4 => array('LIMS_PREFIX_LIMITS', 'chaine', 'LI', 'Pre-fix for Limit objects', 1, 'allentities', 1),
            5 => array('SAMPLES_ADDON_PDF', 'chaine', 'lims_testreport', 'PDF template copied from Crabe. Originally used for invoices.', 1, 'allentities', 1),
        );

access it:

	global $db, $conf;

	//Set prefix
	$this->prefix = ($conf->global->LIMS_PREFIX_LIMITS == '' ? 'LI' : $conf->global->LIMS_PREFIX_LIMITS);

Hi,

From dolibarr version 6 onwards the parameters in custom modules are saved automatically in the database under the table ‘MAIN_DB_PREFIX.const’ (ex: llx_const).
You can access these values directly with the $conf global object like this: $conf->global->YOUR_MODULE_PARAMETER.
Where ‘YOUR_MODULE_PARAMETER’ is the key you set in the $arrayofparameters array in the setup.php file.

Good luck!

1 Like