| |
scollins |
Posted: Wed Aug 08, 2007 9:31 pm Post subject: how do i begin a custom module? |
|
|
Joined: 21 Feb 2007 Posts: 43 Location: Nashville, TN
|
Where to start? What are the non-negotiables of creating a custom module?
i'm interested in making a stripped-down version of the springboard, and i anticipate no database changes at all. i'd like to make a copy of the springboard, and start deleting lines of code. But how do i give this new module a new name, assign it an icon, and integrate it into Copper? Any bits of information are appreciated- thanks! |
|
| |
|
 |
Ben |
Posted: Thu Aug 09, 2007 5:38 am Post subject: |
|
|
|
Hi Shannon,
Realistically you'd want intermediate PHP skills to implement a new module, but someone might like to chime in here with modules they've created? |
|
| |
|
 |
scollins |
Posted: Thu Aug 09, 2007 6:33 pm Post subject: |
|
|
Joined: 21 Feb 2007 Posts: 43 Location: Nashville, TN
|
| Thanks Ben. i'm ready to go with nearly intermediate PHP skills. i guess i'm trying to avoid exploring the code to figure a couple things out- most importantly how a module is defined within Copper, so that i might define a new one that it would recognize. |
|
| |
|
 |
Apophenian |
Posted: Mon Nov 10, 2008 7:29 am Post subject: |
|
|
|
I have started work on a module, and found it not too bad - mainly due to a nice clean architecture (thanks guys!).
I don't have time to go too in depth, but here is how I got started.
1. Under system/modules, create a directory that will contain your module code
2. Create a file in here called index.php
3. in this file create a class that extends the Module class eg:
| Code: |
<?php
class mod_mymodule extends Module
{
...
}
?>
|
4. Create your constructor method and populate it with some defaults
| Code: |
<?php
function mod_mymodule()
{
$this->ModuleName = 'Module name';
$this->ModuleID = 'A nice ID';
$this->RequireLogin = 1;
$this->Public = 1;
parent::Module();
}
?>
|
5. Put in a main method - this is where your module determines what method to call based on the 'action' request parameter
| Code: |
function main()
{
switch (RequestAll('action'))
{
case 'view' : $this->ViewSomething(); break;
default : $this->ViewSomething();
}
}
|
6. From here is where you can start reading data from the database and putting it into your templates, but I haven't got time right now, so will have to post some more later... |
|
| |
|
 |