09 May, 2012

How to create custom module in TikiWiki

2:54 AM

TikiWiki or simply Tiki, is a free and open source wiki-based, content management system and Online office suite written primarily in PHP. Tiki is a powerful all-in-one web-based application, offering collaboration, publishing, commerce, social networking, CRM and office productivity tools. If you have just started your Tiki development then you will frequently need to create custom modules in TikiWiki. In this article I will tell you how to create your custom TikiWiki module from scratch. For creating you own module, you need to add two files in TikiWiki:
  • A php module file
  • A smarty template file

Create the PHP module file

Suppose the name of your module is 'Custom Module', then your module file will be named as 'mod-func-custom_module.php'. This file will contain two important functions. The function with '_info' as suffix will contain the basic information of your module like name, description, required parameters etc. The second function 'module_<module_name>' will contain the core functionality of your module.
<?php
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}

function module_custom_module_info() {
return array(
'name' => tra('Custom Module'),
'description' => tra('This is a custom module.'),
'prefs' => array( ),
'params' => array(
'username' => array(
'required' => true,
'name' => tra('Username'),
'description' => tra('Please enter username.')
),
'Email' => array(
'required' => true,
'name' => tra('email'),
'description' => tra('Please enter Password')
'required' => true,
'name' => tra('db'),
)
'common_params' => array('nonums', 'rows')
);
}

#Create the module function
function module_custom_module( $mod_reference, $module_params ) {
global $smarty, $tikilib, $user;

#Get module parameters
$username = $module_params['username'];
$email = $module_params['email'];

$smarty->assign('username', $username);
$smarty->assign('email', $email);
}

Create the PHP smarty template file

TikiWiki uses smarty as the template engine. Template file is mandatory for module creation. Each module has a separate template file. The convention for naming the template file is as 'mod-<module_name>.tpl'. So our module template file will be 'mod-custom_module.tpl'. In this file we will print the smarty variables assigned in the module PHP file.
Username: {$username}
Email: {$email}
Don't forget to clear your TikiWiki cache before the new module can appear in the modules list.

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

4 comments:

  1. I am really impressed with your writing abilities and also
    with the format for your blog. Is this a paid subject or did you customize
    it yourself? Either way stay up the excellent high quality writing, it is
    uncommon to look a nice weblog like this one today.

    .

    Feel free to surf to my web-site Arabic Books

    ReplyDelete
  2. I do consider all the concepts you have presented for your post.
    They're very convincing and can definitely work. Nonetheless, the posts are too brief for beginners. May you please prolong them a bit from subsequent time? Thanks for the post.

    Here is my homepage; aqui

    ReplyDelete
  3. This post gives clear idea designed for the new users of
    blogging, that in fact how to do blogging.

    My site - free sex tube

    ReplyDelete
  4. Hi! I'm at work surfing around your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the excellent work!

    Look into my web blog; porn pass words ()

    ReplyDelete

 

© 2013 Jquery Giants. All rights resevered. Designed by Templateism

Back To Top