Getting Started With Modules
So, you love tikiwiki and have an idea for a simple addition to the module list?
Modules are a good way to get started on Tiki.
A module is a box of content that may be displayed in the right or left (sometimes top) columns and generally contains a bit of info, a list or an action.
They are called blocks in other CMS-s.
A module, like the rest of Tiki is made up of two files:
- A php file in the modules directory
- A Smarty template in the templates/modules directory
The PHP file
The php file is a simple php file that can be used to assign custom smarty variables to be used in the smarty template that will make up the module display. As an example, open one of the existing module files and take a look.
Example from /tiki/modules/mod-directory_stats.php
<?php if($feature_directory == 'y'){ $ranking = $tikilib->dir_stats(); $smarty->assign('modDirStats',$ranking); } ?>
The Smarty template
The Smarty template file is used to generate the actual module display. This file is self contained and simple. Once again, take a look at one of the existing modules already in the directory.
Example from /tiki/templates/modules/mod-directory_stats.tpl
{if $feature_directory eq 'y'} <div class="box"> <div class="box-title"> {tr}Directory Stats{/tr} </div> <div class="box-data"> {tr}Sites{/tr}: {$modDirStats.valid}<br/> {tr}Sites to validate{/tr}: {$modDirStats.invalid}<br/> {tr}Categories{/tr}: {$modDirStats.categs}<br/> {tr}Searches{/tr}: {$modDirStats.searches}<br/> {tr}Visited links{/tr}: {$modDirStats.visits}<br/> </div> </div> {/if}
Naming your files for success
Keep one thing in mind though, the name of the files is important. The filename will start with "mod-" and end with ".php" and ".tpl" respectively. Everything in between will be displayed in the module list in the admin section of tiki.
You've made it
Just go to the Admin menu and select Modules. You will find your new module in the list that can now be assigned to the left or right.
This isn't very hard
Feel free to edit this page