The basics of module development:

  1. The basic module consists of one folder and two files. In this example, the module will be named "My First Module":

    Folder: mod_myfirstmodule
    PHP File: mod_ myfirstmodule.php
    XML File: mod_ myfirstmodule.xml
    1 Module File Tree
  2. The xml file is the user interface to the module, and contains the name and description, and any parameters the module gets from user input.
    2 Module Title 2 User Interface

  3. The minimum code for the XML file is:
    Code:

    Screenshot:
    3 Xml File Minimum Code
  4. Additional recommended tags for the XML file:

    • author
    • creationDate
    • copyright
    • license
    • authorEmail
    • authorURL
    • version
    • description
    • params
    • module class suffix

    The module class suffix is usually added to a module to allow template class styles to be applied to the module. Most commercial templates have a variety of module styles.
    Code:

    Screenshot:
    4 Xml File Recommended Tags
  5. The PHP file requires minimum code as shown below. This code ensures that the script will only be executed by Joomla and prevents someone from accessing the file directly through the web browser.
    Code:

    Screenshot:
    5 Php File Minimum Code
  6. For our first example, we will output a simple line of html code:
    Code:

    Screenshot:
    First Exercise
  7. Publish the module to your website as you normally would (see Publish a Module to Your Website). View the module on your website.
  8. Next exercise: Get user input and display it in the module.
    1. In the XML file, add the following greeting text input within the params tag (see yellow highlighted code below):
      Code:

      Screenshot:
      thumb_8a_add_text_param
    2. In the PHP file, get the greeting text that was saved from the user input and save into a php variable (see yellow highlighted code below):
      Code:

      Screenshot:
      Get Greeting Parameter
    3. Display the variable in the html (see yellow highlighted code below):
      Code:

      Screenshot:
      thumb_8c_display_greeting_param
    4. Test the module: Open the module in the Module Manager, type "Welcome" in the Greeting input box, save, view on the website.

Watch the Videos:

(This tutorial has a 3-part video)
Permalink
Embed Code
Rating: 2.7 (342 Votes)
View Video
Video Part 1 of 3 for the Module Development: Intro tutorial
Permalink
Embed Code
Rating: 2.6 (328 Votes)
View Video
Video Part 2 of 3 for the Module Development: Intro
Permalink
Embed Code
Rating: 2.8 (304 Votes)
View Video
Video Part 3 of 3 for the Module Development: Intro

iPhone Videos:

 

 

2 Comments Feed

  1. 8-) wow thanksssssssss :-)
  2. very thankful

Add Comment


    • >:o
    • :-[
    • :'(
    • :-(
    • :-D
    • :-*
    • :-)
    • :P
    • :\
    • 8-)
    • ;-)

     

    Rate This:

    1563 Votes

    Share This:

    Save This:

    Sign in to save this to your Favorites.