I Want To Create A Module
Well, it's simple. First, give your module a name. (We'll call ours "test_mod"). Now, create the main file ".php", and put a class in it called pagecache_mod_. Now, there are 5 different triggers (enable, clear, store, process, afterStore), which are done at different times. Each one should have it's own method (named the same as the trigger) in this class. Each method should have 2 arguments (&$data, &$info). Each method should return an array($data, $info). Each trigger looks for different data in the return.
So, in our test module, we'll create two methods, Enable and Store. Here's our file <?php
defined('_VALID_MOS') or die('Direct Access Is Not Permitted');
class pagecache_mod_test_mod {
function enable(&$data, &$info) {
global $database;
$sql = "SELECT value FROM #__pagecache_test_mod WHERE pub = 1";
$database->setQuery($sql);
$dump = $database->loadObjectList();
if(is_array($dump)) {
foreach($dump as $value2) {
if(False!==strpos(_pagecache_current_page,$value2->value)) return(array(false,false));
}
}
return array(true,true);
}
function store(&$data, &$info) {
global $database;
$sql = "SELECT value FROM #__pagecache_test_mod WHERE pub = 1";
$database->setQuery($sql);
$dump = $database->loadObjectList();
if(is_array($dump)) {
foreach($dump as $value2) {
if(strpos($data,$value2->value)!== false ) $data = str_replace($value2->value,"{$value2->value}",$data);
}
}
return array("data"=>$data, "info"=>$info);
}
}
Now, we can optionally create a backend for the module (if you need it). If you are, it needs to be named "admin..php". Now, the variables are set as follows ($option=com_pagecache, $act=modules, $element=). $task will be dependant on the toolbar item clicked within the module admin ("publish", "unpublish", "new", "edit", "delete" are available). The file is included linearly (meaning that there's nothing special about the file, it's just like any other Joomla admin file). So, now that we have a front end file, we need an install file. If you're not including an admin file, then leave the
As you can see, this is a little different from a standard Joomla install file. Note
|

