-
Notifications
You must be signed in to change notification settings - Fork 108
Dynamically Linking Modules
dotProject 2.0 now has a dynamic linking method to allow add-on or other modules to provide tabs in core modules.
To include tabs from offering modules, include this after you've created a tab panel $tabBox:
$tabBox->loadExtras($m, $a);Where $m is the module name and $a is the name of the current PHP file, without the extension. The second parameter is optional, and will load only tabs that are defined for that particular operation. In general the main page (index.php) should not include the second parameter, while view and addedit pages should.
Module developers should note that the tab inclusion code requires that the PHP file should be named systematically to enable it to be found and automatically loaded.
If, for instance, you want to load tabs with this command:
$tabBox->loadExtras($module_to_be_inserted_in);You need to name the tab with this format:
$module_to_be_inserted_in . '_tab.anyname_you_like_for_a_title.php'If you want page-specifics and want to load tabs with this command:
$tabBox->loadExtras($module_to_be_inserted_in, $function);You need to name the tab with this format:
$module_to_be_inserted_in.'_tab.' . $function . '.anyname_you_like_for_a_title.php'Examples of page-specific tabs can be found in the resources module and page-independent tabs can be seen in the files module. These include tabs in the Projects, Companies and Tasks modules.
The tab name will be extrapolated from the 'anyname_you_like_for_a_title' portion of the filename and will have all underscores replaced with spaces and the first letter of each word converted to uppercase.
For example, the file in resources called tasks_tab.view.other_resources.php will be included in the Tasks View page as the "Other Resources" tab.
The loadExtras method will return the number of tabs that are found, and this can be used to determine if the tabBox needs to be shown or not.
Tabs for modules that are disabled or for which the user has no access permission will not be returned.