Creating a package

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:

  1. Component: Manages your database records - here: your "Hello World's"
  2. Site Module: Displays your records in frontend
  3. Backend Module: Displays your records in backend
  4. Content Plugin: Displays your records in content

StartUp

Using the wizard create the following extensions:

  1. Component
    Type: Package Base
    Name: MyTestComponent
  2. Module
    Type: Hello World 2
    Name: MyTestModSite
  3. Module
    Type: Backend Plain
    Name: MyTestModAdmin
  4. Plugin
    Type: Content 1
    Name: MyTestPlugin
Thumbnail

Set up your package

This is required to tell EasyCreator how to create your xml installation file and which extensions your package will contain.

  1. Select your project: Component - MyTestComponent
    go to Building and find the tab named Package
  2. Click Add Module and select your site module MyTestModSite.
    Under Position type left - the position in your frontend template
  3. Click Add Module again and select your admin module MyTestModAdmin.
    Under Position type cpanel - the position in your admin template
  4. Click Add Plugin and select your plugin MyTestPlugin
  5. Click Save

Your package setup has finished.

Thumbnail

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 =;)

2) Frontend module MyTestModSite

/modules/mod_mytestmodsite/helper.php
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public function 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

/modules/mod_mytestmodsite/tmpl/default.php
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<table width="100%">
<tr>
<?php
foreach (array_keys($items[0]) as $key)
{
echo '<td class="sectiontableheader">'.$key.'</th>';
}//foreach
?>
</tr>
<?php
$k = 0;
foreach ($items as $item)
{
echo '<tr class="sectiontableentry'.($k + 1).'">';
foreach ($item as $key=>$value)
{
echo '<td>'.$value.'</td>';
}//foreach
 
echo '</tr>';
$k = 1 - $k;
}//foreach
?>
</table>

3) Backend Module MyTestModAdmin

/administrator/modules/mod_mytestmodadmin/mod_mytestadmin.php
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//--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();
?>
 
<table class="adminlist" width="100%">
<thead>
<tr>
<?php
foreach (array_keys($items[0]) as $key)
{
echo '<th>'.$key.'</th>';
}//foreach
?>
</tr>
</thead>
<?php
$k = 0;
foreach ($items as $item)
{
echo '<tr class="row'.($k).'">';
foreach ($item as $key=>$value)
{
echo '<td>'.$value.'</td>';
}//foreach
 
echo '</tr>';
$k = 1 - $k;
}//foreach
?>
</table>

4) Plugin MyTestPlugin

/plugins/content/mytestplugin.php
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 ($items as $item)
{
$replacement .= ' <tr class="sectiontableentry'.($k+1).'">';
foreach ($item as $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
Thumbnail Thumbnail Thumbnail
Position: 'cpanel'
Thumbnail

Create the install package

Select "Package"
Make sure to select your desired packing format and click on "Create"
Thumbnail

Install your package

Download your package and save it to disk.

Switch over to another Joomla installation and try installing your package

Thumbnail

Have fun packing =;)
Your Easy-Joomla! Team