Take my racing club's website for example: http://portlandkarting.com (hey.. web design isn't my day job

I created a "PKA Dashboard" module that has tabs that control:
* Announcements
* Quick Links
* Which calendar categories show up in the sidebar
* A weather chooser. There is HTML for various cities where we have races stored in the database. The admin chooses which weather element to show in the sidebar.
* A sidebar manager where the admin can design as many sidebars as he wants, choosing content and order, and can choose which one is default. Overriding the default and pointing to another sidebar definition can be controlled by the "Extra 1" field when editing content.
I like to have it all in a dashboard module, so as to have a one-stop-shop to control everything on the front page, instead of having 5 separate modules that the admin needs to find.
Since each website is different, I tend to mix and match elements of different website's dashboard functions into a new creation for that site. This is a bit of a pain because:
* Difficult to create versioned releases of sub-functionality
* Need to create a .module.php script, merging elements of all functions.
* Merging together the install/uninstall functions
* Make sure that actions don't have the same name, etc.
I had an idea a few nights ago and decided to try creating a dashboard module containing tabs for completely independent child modules. You can download my example below:
http://teamwishbone.com/sub_module_test.zip (Note: This was only tested in 1.6.6 "Bonde" ::))
This allows me to have independent modules that can be installed separately with a minor configuration to the dashboard wrapper to control them all. In the example, the dashboard module is 'test_dashboard' and the child modules are 'test_1' and 'test_2'
The configuration change needed for the dashboard module is:
test_dashboard/sub_modules.php
Code: Select all
$sub_modules = array(
'test_1',
'test_2'
);
Excerpt from test_dashboard/action.defaultadmin.php
Code: Select all
include(dirname(__FILE__).'/sub_modules.php');
echo $this->StartTabHeaders();
foreach ($sub_modules as $sub_module) {
if ($gCms->modules[$sub_module]) {
echo($this->SetTabHeader(
$sub_module,
$gCms->modules[$sub_module]['object']->Lang('friendlyname'),
($sub_module == $tab)?true:false
));
}
}
echo $this->EndTabHeaders();
echo $this->StartTabContent();
foreach ($sub_modules as $sub_module) {
if ($gCms->modules[$sub_module]) {
echo $this->StartTab($sub_module, $params);
$gCms->modules[$sub_module]['object']->LoadAdminTab();
echo $this->EndTab();
}
}
echo $this->EndTabContent();
There were a couple of minor issues that I had to work around. The 'save' action of both child modules uses the usual redirect back to the defaultadmin action with the success message. However, I had to redirect it back to the parent module's defaultadmin. The only way I could figure out how to do it was to hard code it with:
Code: Select all
$gCms->modules['test_dashboard']['object']->Redirect($id, 'defaultadmin', $returnid, $params);
Anyways, I have not tested this out in a real world application. The next time I create a custom control panel, I'll take the time and convert my various tabs into standalone modules and should be able to mix-n-match them into a custom dashboard in minutes!
I really have no idea how useful this will be, just sorta thinking/testing out loud. Just thought I'd share this idea.