Quick links: Content - sections - sub sections
EN FR

From your classes, you can access to some global variables created by Jelix.

$gJConfig

This object allow you to access to the configuration of the application. Each of its properties correspond to a configuration parameter stored in the defaultconfig.ini.php or the ini file of the entry point.

Calling gJConfig

Here is an example in a function/method:


function test()
{
   global $gJConfig;
   $gJConfig->urlengine['basePath'];

// or, without using the global keyword
   $GLOBALS['gJConfig']->urlengine['basePath'];
}

Accessing to parameters

If the config.ini.php file of the entry point has this content:


startModule = "testapp"
startAction = "main:index"
 
[coordplugins]
autolocale = index/autolocale.ini.php
 
[responses]
html=myHtmlResponse

Then you can retrieve this parameters, by doing this:


function test()
{
   global $gJConfig;

   $a = $gJConfig->startModule; // "testapp"
   $b = $gJConfig->coordplugins['autolocale']; // "index/autolocale.ini.php"
}

$gJCoord

The $gJCoord object is the instance of a jCoordinator class, created in the entry point. You can then access to its method and properties to retrieve some informations and objects : plugins list, the current jResponse object, the current jRequest object, the current module name and action name etc.

Calling gJCoord


function test()
{
   global $gJCoord;
   $gJCoord->request->type;

// or
   $GLOBALS['gJCoord']->request->type; 
}

Example

If your entry point is called with the URL /index.php?test=1, here how to retrieve parameters and the script name:


function test()
{
   global $gJCoord;

   $a = $gJCoord->request->urlScriptName; // "index.php"
   $b = $gJCoord->request->params['test']; // 1
}