This is about creating a "package" with EasyCreator. A "package" consists of multiple extensions - e.g. a component and various modules and plugins.
Our package will contain four extensions:
Component: Manages your database records - here: your "Hello World's"
Site Module: Displays your records in frontend
Backend Module: Displays your records in backend
Content Plugin: Displays your records in content
StartUp
Using the wizard create the following extensions:
Component Type: Package Base Name: MyTestComponent
Module Type: Hello World 2 Name: MyTestModSite
Module Type: Backend Plain Name: MyTestModAdmin
Plugin Type: Content 1 Name: MyTestPlugin
Set up your package
This is required to tell EasyCreator how to create your xml installation file and which extensions your package will contain.
Select your project: Component - MyTestComponent go to Building and find the tab named Package
Click Add Module and select your site module MyTestModSite. Under Position type left - the position in your frontend template
Click Add Module again and select your admin module MyTestModAdmin. Under Position type cpanel - the position in your admin template
Click Add Plugin and select your plugin MyTestPlugin
Click Save
Your package setup has finished.
We go for the code
We will modify the created modules and the plugin to pull the data from the components table and display it in a HTML table. Remember - this is for demo purpose only =;)
publicfunction getItems($userCount) { //--Get a reference to the database $db=&JFactory::getDBO(); //--Get a list of all items $query='SELECT *' .' FROM `#__mytestcomponent`'; $db->setQuery($query); $items=($items=$db->loadAssocList()) ? $items:array(); return$items; }//function
function mytestplugin(&$row,&$params,$page=0) { if(!strpos($row->text,'{triggerMyTestPlugin')) { //--The tag is not found in content - abort.. return; } //--Search for this tag in the content $regex='/{triggerMyTestPlugin\s*.*?}/i'; // get a reference to the database $db=&JFactory::getDBO(); // get a list of all users $query='SELECT *' .' FROM `#__mytestcomponent`'; $db->setQuery($query); $items=($items=$db->loadAssocList()) ? $items:array(); $replacement=''; $replacement.='<table width="50%">'; $replacement.=' <tr>'; foreach(array_keys($items[0])as$key) { $replacement.=' <th class"sectiontableheader">'.$key.'</th>'; }//foreach $replacement.=' </tr>'; $k=0; foreach($itemsas$item) { $replacement.=' <tr class="sectiontableentry'.($k+1).'">'; foreach($itemas$key=>$value) { $replacement.=' <td>'.$value.'</td>'; }//foreach $replacement.=' </tr>'; $k=1-$k; }//foreach $replacement.='</table>'; //--Replace tag in content $row->text=preg_replace($regex,$replacement,$row->text); return; }//function
Screenshots
1) Component
2) Frontend Module
3) Backend Module
4) Content Plugin
Position: 'cpanel'
Create the install package
Select "Package" Make sure to select your desired packing format and click on "Create"
Install your package
Download your package and save it to disk.
Switch over to another Joomla installation and try installing your package