User

User:Rvsjoen/tutorial/Developing a Module/Part 02

From Joomla! Documentation

Revision as of 15:23, 13 March 2012 by Rvsjoen (talk | contribs) (Created page with "= Adding a module template = In most cases, we want our module to have the ability to display output using a template. We could theoretically code all of this directly into the ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Adding a module template

In most cases, we want our module to have the ability to display output using a template. We could theoretically code all of this directly into the module php file but using a separate file increases flexibility and gives us the option to override the module output in a template.

So in order to create a module template we need to do two things

  1. Create the template
  2. Tell the module to load the template and display it

With your favorite editor, create the following file

tmpl/mod_helloworld.php

<?php

/**
 * @package     Joomla.Tutorials
 * @subpackage  Module
 * @copyright   Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license     License GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access to this file
defined('_JEXEC') or die;

?>

<p>Hello World! I am a module</p>