- Create a folder called mod_helloworld in modules
- Create a mod_helloworld.php file
- Create a mod_helloworld.xml file
- Create a helper.php file
- Create a template file tmpl/default.php
- Discover new modules by going to “Extension Manager” -> “Discover”
The code for mod_helloworld.php
<?php defined('_JEXEC') or die; // no direct access allowed require_once dirname(__FILE__).DS.'helper.php'; // get helper files $hello = modHelloWorldHelper::getHello($params); require JModuleHelper::getLayoutPath('mod_helloworld'); ?>
The helper.php file
<?php class modHelloWorldHelper { /** * Retrieves the hello message * * @param array $params An object containing the module parameters * @access public */ function getHello( $params ) { return 'Hello, World!'; } } ?>
Include the template file for the default view
<?php defined('_JEXEC') or die; echo $hello; ?>
The mod_helloworld.xml file
<?xml version="1.0" encoding="utf-8"?> <extension type="module" version="1.7.0" client="site" method="upgrade"> <name>Hello World!</name> <author>Harshal Shah </author> <version>1.7.0</version> <description>Reinholds simple Hello World module.</description> <files> <filename module="mod_helloworld">mod_helloworld.php</filename> <filename>mod_helloworld.xml</filename> <filename>index.html</filename> <filename>helper.php</filename> <filename>tmpl/default.php</filename> <filename>tmpl/index.html</filename> </files> <params> </params> </extension>
Create both index.html files to prevent direct directory browsing
<html><body></body></html>
thank you very much
ReplyDeletethank you very much, it is really really good
ReplyDelete