shoutmix

28 Juni 2010

cara bikin module di joomla 1.5

ini buat joomla 1.5 kukasi nama mod_mujur
mod_mujur.xml
HTML Code:

<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
    <!-- Name of the Module -->
        <name>Maju Jujur Untuk Rakyat</name>

    <!-- Name of the Author -->
        <author>Mujur</author>

    <!-- Version Date of the Module -->
        <creationDate>Juny 26, 2010 </creationDate>

    <!-- Copyright information -->
        <copyright>All rights reserved by orang mujur.</copyright>

    <!-- License Information -->
        <license>GPL 2.0</license>

    <!-- Author's email address -->
        <authorEmail>gundambison@yahoo.com</authorEmail>

    <!-- Author's website -->
        <authorUrl>http://ngocehh.com</authorUrl>

    <!-- Module version number -->
        <version>0.0.1</version>

    <!-- Description of what the module does -->
        <description>Menu Mujur</description>

    <!-- Listing of all files that should be installed for the module to function -->
        <files>
        <!-- The "module" attribute signifies that this is the main controller file -->
                <filename module="mod_mujur">mod_mujur.php</filename>
                <filename>index.html</filename>
                <filename>helper.php</filename>
                <filename>tmpl/default.php</filename>
                <filename>tmpl/index.html</filename>

        </files>
    <languages>
        <!-- Any language files included with the module -->
        <language tag="en-GB">en-GB.mod_mujur.ini</language>
    </languages>

    <!-- Optional parameters -->
        <params>
        <!-- parameter to allow placement of a module class suffix for the module table / xhtml display -->
                <param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="PARAMMODULECLASSSUFFIX" />

        <!-- just gives us a little room between the previous paramter and the next -->
                <param name="@spacer" type="spacer" default="" label="" description="" />

        <!-- A parameter that allows an administrator to modify the number of users that this module will display -->
        <param name="usercount" type="text" default="5" label="LABEL USER COUNT" description="DESC USER COUNT" />
         <param name="pembuat" type="text" default="5" label="Nama Pengarang" description="DESC Author" />
         <param name="userPermision" type="text" default="5" label="Permision" description="DESC Author" />
        
        
    </params>

   
</install>
buat file bahasanya.. isinya cuma begini doank

en-GB.mod_mujur.ini
Code:

LABEL USER COUNT=User Count
DESC USER COUNT=The number of users to display
RANDOM USERS=Random Users for Hello World2
USER LABEL=%s is a randomly selected user
PERMISION=Permision Name %s
PERMISION DETAIL=Detail %s
dan gw bahkan gk pernah pake file ini lho
mod_mujur.php
PHP Code:
<?php
//don't allow other scripts to grab and execute our file
defined('_JEXEC') or die('Direct Access to this location is not allowed.');

// include the helper file
require_once(dirname(__FILE__).DS.'helper.php');
 
// get a parameter from the module's configuration
$userCount = $params->get('usercount');
$creator =   $params->get('pembuat'); 
$uPermision = $params->get('userPermision');

// include the template for display
require(JModuleHelper::getLayoutPath('mod_mujur'));
untuk nampilin isi dari file bahasa
PHP Code:
$userCount = $params->get('usercount');
$creator =   $params->get('pembuat'); 
$uPermision = $params->get('userPermision'); 
helper.php
PHP Code:
<?php
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
 
class ModMujurHelper
{
    /**
     * Returns a list of post items
    */
    public function getItems($userCount)
    {
        // get a reference to the database
        $db = &JFactory::getDBO();
 
        // get a list of $userCount randomly ordered users 
        $query = 'SELECT a.name FROM `#__users` AS a ORDER BY rand() LIMIT ' . $userCount  . '';
 
        $db->setQuery($query);
        $items = ($items = $db->loadObjectList())?$items:array();
 
        return $items;
    } //end getItems

} //end class 
terakhir.. bikin folder tmpl lalu isi di dalamnya file default.php
default.php
PHP Code:
<?php defined('_JEXEC') or die('Restricted access'); 
$txt="apa kabar dunia!!!";
echo $txt;
Zip semua file ini lalu install ke joomla kamu

0 komentar:

Posting Komentar

Powered By Blogger