Lịch sử chỉnh sửa
Ngày tháng Version Mô tả Người viết
06/2012 Joomla 2.5.4 DVMS
Mục lục
1. Cấu trúc thư mục chuẩn của một module: .................................................................. 3
2. Mod_newday.xml : ........................................................................................................ 3
3. File đầu vào của module ( mod_newday.php ) ............................................................. 4
4. File xử lý (helper.php) ................................................................................................... 4
5. file layout (default.php) ................................................................................................. 5
THÔNG TIN LIÊN HỆ HỖ TRỢ..................................................................................... 5
www.dvms.vn
1. Cấu trúc thư mục chuẩn của một module:
2. Mod_newday.xml :
- là file đặc tả module và các tham số của module.
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="2.5.0" method="install">
<name>New Day!</name>
<creationDate>07/06/2012</creationDate>
<author>N.V.L</author>
<authorEmail>vanlinh@vht.com.vn</authorEmail>
<authorUrl>http://www.vht.com.vn</authorUrl>
<copyright>Copyright Info</copyright>
<license>License Info</license>
<version>1.0</version>
<description>Chào ngày mới </description>
<!-- khai bao file cua -->
<files>
<filename module="mod_newday">mod_newday.php</filename>
<filename>mod_newday.xml</filename>
<filename>helper.php</filename>
<folder>tmpl</folder>
<folder>language</folder>
</files>
<!-- khai bao file ngon ngu -->
<languages folder="language">
<language tag="vi-VN">vi-VN/vi-VN.mod_newday.ini</language>
<language tag="vi-VN">vi-VN/vi-VN.mod_newday.sys.ini</language>
</languages>
<!-- tham so cua module -->
www.dvms.vn
<config>
<fields name="params">
<fieldset name="basic">
<field
name="greeting"
type="text"
default="new day"
label="MOD_NEWDAY_GREETING_LABEL"
description="MOD_NEWDAY_GREETING_DESC"
/>
</fieldset>
</fields>
</config>
</extension>
3. File đầu vào của module ( mod_newday.php )
<?php
// No direct access to this file
defined('_JEXEC') or die;
JLoader::register('modNewDayHelper', JPATH_BASE.'/modules/mod_newday/helper.php');
require JModuleHelper::getLayoutPath('mod_newday', $params->get('layout', 'default'));
4. File xử lý (helper.php)
<?php
// No direct access to this file
defined('_JEXEC') or die;
class modNewDayHelper
{
public static function getGreeting() {
return "Message from the helper";
}
/* đếm số session trong bảng session */
public static function getCurrentUsers() {
$db = JFactory::getDBO();
$db->setQuery($db->getQuery(true)
->select("COUNT(*) as users")
->from("#__session")
);
return $db->loadResult();
}
}
www.dvms.vn
5. file layout (default.php)
<?php
// No direct access to this file
defined('_JEXEC') or die;
?>
<p><?php echo $params->get('greeting', JText::_('MOD_NEWDAY_GREETING_DEFAULT'));
?></p>
<p><?php echo modNewDayHelper::getGreeting(); ?></p>
<p>There are <?php echo modNewDayHelper::getCurrentUsers(); ?> user(s) logged in</p>
Tài liệu tham khảo:
http://docs.joomla.org/User:Rvsjoen/tutorial/Developing_a_Module
http://www.youtube.com/watch?v=Qd93be8YRNY
CHÚC THÀNH CÔNG!
THÔNG TIN LIÊN HỆ HỖ TRỢ
DVMS
(08) 360 289 37 info@dvms.vn
www.DVMS.vn
www.dvms.vn