SlideShare uma empresa Scribd logo
1 de 49
Vishwash Gaur

                  © 2012 Vishwash Gaur. All rights reserved.
All registered trademarks, logos, products and service names belong to their
                              respective owners.
       Image Credit: http://ayadipro.com/blog/high-tech-education/25-improvements-in-joomla-2-5/
Disclaimer: Images used on this slide are for representative purposes only and belong to their respective owners.
   Basic knowledge of HTML, PHP and MySQL
   Interest in MVC and CMS frameworks to reduce development
    time
   A web server with PHP/MySQL installed on it
   Joomla! 2.5 package downloaded and installed
    ◦ it can be downloaded from http://www.joomla.org/download.html


   NOTE: This presentation is focused for the beginners in Joomla! and would
    cover only a basic overview due to limited time. Further details can be
    discussed separately later.
Hands on workshop to
develop a basic Joomla!
Module and component
   Let’s create a module called “Reviews” for this
    workshop which will display customer reviews
    on the web page
   It will allow us to display a simple text in a
    pre-defined Joomla module position
   Once this is done, we will fetch data for the
    module from DB
   modules>mod_reviews
    ◦   mod_reviews.php
    ◦   mod_reviews.xml
    ◦   helper.php
    ◦   index.html
    ◦   tmpl/default.php
    ◦   tmpl/index.html
<?php
//license details here

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );

//load helper class and function
$reviews = modReviewsHelper::getReviews( $params );

//load the layout file from template views
require( JModuleHelper::getLayoutPath( 'mod_reviews' ) );
?>
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

As it suggests, this line checks to make sure that this
   file is being included from the Joomla! application.
It is necessary to prevent variable injection and other
   potential security concerns.
// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );
The helper class is defined in our helper.php file.
   This file is included with a require_once statement.
It allows to include necessary functions for the
   module functionality. Helper file may include basic
   calculations, DB connection and query code.
//load helper class and function
$reviews = modReviewsHelper::getReviews( $params );

This line allows to invoke the appropriate helper class method
  to retrieve the data.
Currently, we do not use any parameters but it is allowed in this
  module for future extensibility.
//load the layout file from template views
require( JModuleHelper::getLayoutPath( 'mod_reviews' ) );

This line includes the template to display the output.
<?xml version="1.0" encoding="utf-8"?>
<extension
  type="module"
  version="2.5"
  client="site"
  method="upgrade">
  <name>Reviews</name>
  <author>Vishwash Gaur</author>
  <version>2.5.0</version>
  <description>An review module.</description>
  <files>
     <filename module="mod_reviews">mod_reviews.php</filename>
     <filename>index.html</filename>
     <filename>helper.php</filename>
         <folder>tmpl</folder>
         <filename>mod_reviews.xml</filename>
  </files>
</extension>

                        This file is used to specify which files the installer needs to copy
                        and is used by the Module Manager to determine which
                        parameters are used to configure the module.
<extension type="module“ version="2.5“
 client="site“ method="upgrade">

This line tells to Joomla! that selected
 extension type is module and compatible with
 Joomla version 2.5.
Extension type is also defined for site which
 means it will be available for front-end.
<name>Reviews</name>
<author>Vishwash Gaur</author>
<version>2.5.0</version>
<description>An review module.</description>
<files>
      <filename
  module="mod_reviews">mod_reviews.php</filename>
      <filename>index.html</filename>
      <filename>helper.php</filename>
       <folder>tmpl</folder>
       <filename>mod_reviews.xml</filename>
  </files>
<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
  <name>Hello, World!</name>
  <author>John Doe</author>
  <version>1.5.0</version>
  <description>A simple Hello, World! module.</description>
  <files>
     <filename>mod_reviews.xml</filename>
     <filename module="mod_reviews">mod_reviews.php</filename>
     <filename>index.html</filename>
     <filename>helper.php</filename>
     <filename>tmpl/default.php</filename>
     <filename>tmpl/index.html</filename>
  </files>
  <params>
  </params>
</install>
<?php
//license details here

class modReviewsHelper
{
   /**
    * Retrieves the reviews
    *
    * @param array $params An object containing the module parameters
    * @access public
    */
   function getReviews( $params )
   {
      return 'I am a happy user!';
   }
}
?>
<html><body bgcolor="#FFFFFF"></body></html>

This file is included to prevent directory browsing. It can be
  event left blank and whenever someone will access the
  directory then this file will be default loaded.
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
//print user reviews
echo $reviews;
?>
<html><body bgcolor="#FFFFFF"></body></html>

This file is included to prevent directory browsing. It can be
  event left blank and whenever someone will access the
  directory then this file will be default loaded.
   Once a base module is ready, we can start using it
    immediately in Joomla.
   In Joomla 1.5, it was auto-detected but in Joomla
    2.5, we would need to discover a newly developed
    extension from admin panel.
   For this, please login to admin panel and go to Top
    menu>extensions>extension manager
   Click on the discover tab and refresh the data
Go tot extension
manager
Click on the
discover button
to find newly
developed
extensions
If your programming is
correct, it will find your newly
developed extension.
Select the extension and click
on install button to setup the
extension.
   Once a module is added in the Joomla! System, it
    has to be defined on a position using module
    manager.
   It will allow module to display in the front-end.
Go to module manager
and click on “New”
button
Select your newly
developed module
Define module
position in active
template and set
other parameters and
pages to display the
module.
I give it position 6 in
Beez_20 template.
Module successfully
saved, now move to
front-end to check this.
You can
see user
review
here
   I can’t see the module
    ◦ Check if you have selected correct position in the
      active template
   With the previous example, you can display one
    static customer review but what if there are many
    customer reviews which should be dynamically
    loaded on the page.
   Let’s do that!
   Using phpMyAdmin or any other DB management
    tool, create a table called __reviews in the Joomla
    DB
   Add required fields i.e. id, name, city and feedback
    in the table
   Kindly note this example is meant to be very basic
    for easy understanding
Create table and add
fields in the database.
Note: Ideally, it is the
part of component.
I have done some entries in the DB directly
for the demo purpose. It should happen
via a back-end component in real
environment.
   Now, since we are not doing any static code
    and want to load reviews dynamically from
    the database, we need to make some changes
    in below files:
    ◦ mod_reviews.php – minor change
    ◦ helper.php – major change for DB connection and
      query
    ◦ tmpl/default.php – minor change
    ◦ tmpl/reviews.php – new template file added
<?php
//license details here

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );

//load helper class and function
//$reviews = modReviewsHelper::getReviews( $params );
$rows = modReviewsHelper::getReviews( $params );


//load the layout file from template views
require( JModuleHelper::getLayoutPath( 'mod_reviews' ) );
?>
<?xml version="1.0" encoding="utf-8"?>
<extension
  type="module"
  version="2.5"
  client="site"
  method="upgrade">
  <name>Reviews</name>
  <author>Vishwash Gaur</author>
  <version>2.5.0</version>
  <description>An review module.</description>
  <files>
     <filename module="mod_reviews">mod_reviews.php</filename>
     <filename>index.html</filename>
     <filename>helper.php</filename>
         <folder>tmpl</folder>
         <filename>mod_reviews.xml</filename>
  </files>
</extension>
<?php
//license details here

class modReviewsHelper
{
   /**
    * Retrieves the reviews
    *
    * @param array $params An object containing the module parameters
    * @access public
    */
   function getReviews( $params )
   {
      return 'I am a happy user!';
   }
}
?>
<?php
//license details here


class modReviewsHelper
{
    /**
        * Retrieves the reviews
        * @param array $params An object containing the module parameters
        * @access public
                                                                            For the demonstration
        */
    function getReviews( $params )
                                                                            purpose, kindly understand
    {
          //return 'I am a happy user!';
                                                                            and note that Joomla! uses
             //limit the number of items to load from DB
             $items = $params->get('items', 10);
                                                                            it’s own code conventions
             //make DB connection
                                                                            to make DB connections and
             $db=& JFactory::getDBO();
             $result= null;
                                                                            to run a query. It allows in
             //run db query
             $query = 'SELECT * FROM #__reviews';
                                                                            less code and standardized
             $db->setQuery($query, 0, $items);
             $rows = $db->loadObjectList();
                                                                            approach.
             //display and handle error warning
             if ($db->getErrorNum()) {
             JError::raiseWarning( 500, $db->stderr(true) );
             }
             return $rows;
    }
/**
    * Function to display rating and reviews via views
    * @param array $params An object containing the module parameters
    * @access public
    */
  function renderReviews(&$reviews, &$params)
  {
      //variable to store db value of a particular record link to open in detailed view
      $link = JRoute::_('index.php?option=com_reviews&id='.$reviews->id.'&task=view');

      //call template view for display
      require(JModuleHelper::getLayoutPath('mod_reviews' , 'reviews'));
 }
}
?>




                                         This component doesn’t exists in the system but we have planned
                                         it for future use or next demo of component development.
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
//print user reviews
//echo $reviews;
foreach($rows as $row)
{
  modReviewsHelper::renderReviews($row, $params);
}
?>
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); ?>
<table width="95%">
<tr><td>
<strong><?php echo ucwords(strtolower($reviews->name)); ?></strong>
<br />
<span style="font-size:9px; margin-top:-5px;">
<?php echo ucwords(strtolower($reviews->city));?></span><br />
</td>
</tr>
<tr>
<td><?php echo wordwrap($reviews->feedback,130, "<br />n");?></td>
</tr>
</table>
Dynamic
records from DB
   Get your XAMP, LAMP, MAMP or WAMP environment
    ready
   Install and experiment Joomla! Locally
   Checkout online references
   Get a book
   Visit Joomla! JED, Forums and user groups
   Help each other and learn from experiences
   I look forward to learn and share more with you in
    future too.

   I can be reached easily at my blog
    www.vishwashgaur.com and/or using twitter
    @vishwashgaur
   XAMP: http://www.apachefriends.org/en/xampp.html
   Joomla!: http://www.joomla.org/
   JED: http://extensions.joomla.org/
   Joomla! Forum: http://forum.joomla.org/
   Joomla! Magazine: http://magazine.joomla.org/authors/itemlist/user/65-Nicholas-G-Antimisiaris
   Joomla documentation: http://docs.joomla.org/
   Joomla 2.5 essential training: http://www.lynda.com/Joomla-tutorials/Joomla-Essential-Training/95699-2.html
   Joomla! For beginners guide 2012: http://www.danconia.com/joomla-for-beginners-guide-2012.html
   Joomla! Developers guide: http://cocoate.com/sites/cocoate.com/files/private/jdev.pdf

Mais conteúdo relacionado

Mais procurados

A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2Jim Driscoll
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Courseguest764934
 
Building and managing java projects with maven part-III
Building and managing java projects with maven part-IIIBuilding and managing java projects with maven part-III
Building and managing java projects with maven part-IIIprinceirfancivil
 
Securing JSF Applications Against the OWASP Top Ten
Securing JSF Applications Against the OWASP Top TenSecuring JSF Applications Against the OWASP Top Ten
Securing JSF Applications Against the OWASP Top TenDavid Chandler
 
Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage componentsBenoit Marchant
 
JSF basics
JSF basicsJSF basics
JSF basicsairbo
 
Spring Web Views
Spring Web ViewsSpring Web Views
Spring Web ViewsEmprovise
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsRaghavan Mohan
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0Arun Gupta
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204ealio
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryPamela Fox
 

Mais procurados (18)

A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Java server faces
Java server facesJava server faces
Java server faces
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
 
Building and managing java projects with maven part-III
Building and managing java projects with maven part-IIIBuilding and managing java projects with maven part-III
Building and managing java projects with maven part-III
 
Securing JSF Applications Against the OWASP Top Ten
Securing JSF Applications Against the OWASP Top TenSecuring JSF Applications Against the OWASP Top Ten
Securing JSF Applications Against the OWASP Top Ten
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage components
 
JSF basics
JSF basicsJSF basics
JSF basics
 
Jsp Introduction Tutorial
Jsp Introduction TutorialJsp Introduction Tutorial
Jsp Introduction Tutorial
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Spring Web Views
Spring Web ViewsSpring Web Views
Spring Web Views
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & Witchery
 
Working with Servlets
Working with ServletsWorking with Servlets
Working with Servlets
 
Javabeans .pdf
Javabeans .pdfJavabeans .pdf
Javabeans .pdf
 

Destaque

Ed. Technology Council Open Source Presentation
Ed. Technology Council Open Source PresentationEd. Technology Council Open Source Presentation
Ed. Technology Council Open Source PresentationHillside Community School
 
Permanent hosting at Joomla.com
Permanent hosting at Joomla.comPermanent hosting at Joomla.com
Permanent hosting at Joomla.comDouglasPickett
 
Joomla Hosting Done the Right Way
Joomla Hosting Done the Right WayJoomla Hosting Done the Right Way
Joomla Hosting Done the Right Waygswahhab
 
Advanced Akeeba Backup (Joomla! Day Denmark 2012)
Advanced Akeeba Backup (Joomla! Day Denmark 2012)Advanced Akeeba Backup (Joomla! Day Denmark 2012)
Advanced Akeeba Backup (Joomla! Day Denmark 2012)Nicholas Dionysopoulos
 
Website Localization Made Easy - Proz.com webinar presentation by Balazs Benedek
Website Localization Made Easy - Proz.com webinar presentation by Balazs BenedekWebsite Localization Made Easy - Proz.com webinar presentation by Balazs Benedek
Website Localization Made Easy - Proz.com webinar presentation by Balazs BenedekSkawa Innovation
 
Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...
Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...
Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...Nicholas Dionysopoulos
 
Windows server 2012 - installing active directory domain server
Windows server 2012 - installing active directory domain serverWindows server 2012 - installing active directory domain server
Windows server 2012 - installing active directory domain serverahmadbahaj
 
Install Windows Server 2012 Step-by-Step
Install Windows Server 2012 Step-by-StepInstall Windows Server 2012 Step-by-Step
Install Windows Server 2012 Step-by-StepMehdi Poustchi Amin
 
Active Directory Domain Services Installation & Configuration - Windows Ser...
Active Directory Domain Services  Installation & Configuration  - Windows Ser...Active Directory Domain Services  Installation & Configuration  - Windows Ser...
Active Directory Domain Services Installation & Configuration - Windows Ser...Adel Alghamdi
 
Install Windows Server 2008 Step-by-Step
Install Windows Server 2008 Step-by-StepInstall Windows Server 2008 Step-by-Step
Install Windows Server 2008 Step-by-StepMehdi Poustchi Amin
 

Destaque (12)

Ed. Technology Council Open Source Presentation
Ed. Technology Council Open Source PresentationEd. Technology Council Open Source Presentation
Ed. Technology Council Open Source Presentation
 
Permanent hosting at Joomla.com
Permanent hosting at Joomla.comPermanent hosting at Joomla.com
Permanent hosting at Joomla.com
 
Joomla Hosting Done the Right Way
Joomla Hosting Done the Right WayJoomla Hosting Done the Right Way
Joomla Hosting Done the Right Way
 
Advanced Akeeba Backup (Joomla! Day Denmark 2012)
Advanced Akeeba Backup (Joomla! Day Denmark 2012)Advanced Akeeba Backup (Joomla! Day Denmark 2012)
Advanced Akeeba Backup (Joomla! Day Denmark 2012)
 
Website Localization Made Easy - Proz.com webinar presentation by Balazs Benedek
Website Localization Made Easy - Proz.com webinar presentation by Balazs BenedekWebsite Localization Made Easy - Proz.com webinar presentation by Balazs Benedek
Website Localization Made Easy - Proz.com webinar presentation by Balazs Benedek
 
Joomla! security jday2015
Joomla! security jday2015Joomla! security jday2015
Joomla! security jday2015
 
Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...
Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...
Joomla! Day Poland 2012 - Advanced Akeeba Backup - Beyond just backing up you...
 
Windows server 2012 - installing active directory domain server
Windows server 2012 - installing active directory domain serverWindows server 2012 - installing active directory domain server
Windows server 2012 - installing active directory domain server
 
Joomla Presentations
Joomla PresentationsJoomla Presentations
Joomla Presentations
 
Install Windows Server 2012 Step-by-Step
Install Windows Server 2012 Step-by-StepInstall Windows Server 2012 Step-by-Step
Install Windows Server 2012 Step-by-Step
 
Active Directory Domain Services Installation & Configuration - Windows Ser...
Active Directory Domain Services  Installation & Configuration  - Windows Ser...Active Directory Domain Services  Installation & Configuration  - Windows Ser...
Active Directory Domain Services Installation & Configuration - Windows Ser...
 
Install Windows Server 2008 Step-by-Step
Install Windows Server 2008 Step-by-StepInstall Windows Server 2008 Step-by-Step
Install Windows Server 2008 Step-by-Step
 

Semelhante a Simple module Development in Joomla! 2.5

Techgig Webinar: Joomla Introduction and Module Development June 2012
Techgig Webinar: Joomla Introduction and Module Development June 2012Techgig Webinar: Joomla Introduction and Module Development June 2012
Techgig Webinar: Joomla Introduction and Module Development June 2012Vishwash Gaur
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Modules and Components Introduction in Joomla! 2.5
Modules and Components Introduction in Joomla! 2.5Modules and Components Introduction in Joomla! 2.5
Modules and Components Introduction in Joomla! 2.5Vishwash Gaur
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress PluginBrad Williams
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeRakesh Kushwaha
 
crtical points for customizing Joomla templates
crtical points for customizing Joomla templatescrtical points for customizing Joomla templates
crtical points for customizing Joomla templatesamit das
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practicesdanpastori
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development Mage Guru
 
Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Phase2
 
Joomla Day India 2009 Business Logic With The Mvc
Joomla Day India 2009   Business Logic With The MvcJoomla Day India 2009   Business Logic With The Mvc
Joomla Day India 2009 Business Logic With The MvcAmit Kumar Singh
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughBradley Holt
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
Using Drupal Features in B-Translator
Using Drupal Features in B-TranslatorUsing Drupal Features in B-Translator
Using Drupal Features in B-TranslatorDashamir Hoxha
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 

Semelhante a Simple module Development in Joomla! 2.5 (20)

Techgig Webinar: Joomla Introduction and Module Development June 2012
Techgig Webinar: Joomla Introduction and Module Development June 2012Techgig Webinar: Joomla Introduction and Module Development June 2012
Techgig Webinar: Joomla Introduction and Module Development June 2012
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Modules and Components Introduction in Joomla! 2.5
Modules and Components Introduction in Joomla! 2.5Modules and Components Introduction in Joomla! 2.5
Modules and Components Introduction in Joomla! 2.5
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
crtical points for customizing Joomla templates
crtical points for customizing Joomla templatescrtical points for customizing Joomla templates
crtical points for customizing Joomla templates
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practices
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7
 
Joomla Day India 2009 Business Logic With The Mvc
Joomla Day India 2009   Business Logic With The MvcJoomla Day India 2009   Business Logic With The Mvc
Joomla Day India 2009 Business Logic With The Mvc
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
 
RequireJS
RequireJSRequireJS
RequireJS
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Using Drupal Features in B-Translator
Using Drupal Features in B-TranslatorUsing Drupal Features in B-Translator
Using Drupal Features in B-Translator
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 

Último

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 

Último (20)

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 

Simple module Development in Joomla! 2.5

  • 1. Vishwash Gaur © 2012 Vishwash Gaur. All rights reserved. All registered trademarks, logos, products and service names belong to their respective owners. Image Credit: http://ayadipro.com/blog/high-tech-education/25-improvements-in-joomla-2-5/ Disclaimer: Images used on this slide are for representative purposes only and belong to their respective owners.
  • 2. Basic knowledge of HTML, PHP and MySQL  Interest in MVC and CMS frameworks to reduce development time  A web server with PHP/MySQL installed on it  Joomla! 2.5 package downloaded and installed ◦ it can be downloaded from http://www.joomla.org/download.html  NOTE: This presentation is focused for the beginners in Joomla! and would cover only a basic overview due to limited time. Further details can be discussed separately later.
  • 3. Hands on workshop to develop a basic Joomla! Module and component
  • 4. Let’s create a module called “Reviews” for this workshop which will display customer reviews on the web page  It will allow us to display a simple text in a pre-defined Joomla module position  Once this is done, we will fetch data for the module from DB
  • 5. modules>mod_reviews ◦ mod_reviews.php ◦ mod_reviews.xml ◦ helper.php ◦ index.html ◦ tmpl/default.php ◦ tmpl/index.html
  • 6. <?php //license details here // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); // Include the syndicate functions only once require_once( dirname(__FILE__).DS.'helper.php' ); //load helper class and function $reviews = modReviewsHelper::getReviews( $params ); //load the layout file from template views require( JModuleHelper::getLayoutPath( 'mod_reviews' ) ); ?>
  • 7. // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); As it suggests, this line checks to make sure that this file is being included from the Joomla! application. It is necessary to prevent variable injection and other potential security concerns.
  • 8. // Include the syndicate functions only once require_once( dirname(__FILE__).DS.'helper.php' ); The helper class is defined in our helper.php file. This file is included with a require_once statement. It allows to include necessary functions for the module functionality. Helper file may include basic calculations, DB connection and query code.
  • 9. //load helper class and function $reviews = modReviewsHelper::getReviews( $params ); This line allows to invoke the appropriate helper class method to retrieve the data. Currently, we do not use any parameters but it is allowed in this module for future extensibility.
  • 10. //load the layout file from template views require( JModuleHelper::getLayoutPath( 'mod_reviews' ) ); This line includes the template to display the output.
  • 11. <?xml version="1.0" encoding="utf-8"?> <extension type="module" version="2.5" client="site" method="upgrade"> <name>Reviews</name> <author>Vishwash Gaur</author> <version>2.5.0</version> <description>An review module.</description> <files> <filename module="mod_reviews">mod_reviews.php</filename> <filename>index.html</filename> <filename>helper.php</filename> <folder>tmpl</folder> <filename>mod_reviews.xml</filename> </files> </extension> This file is used to specify which files the installer needs to copy and is used by the Module Manager to determine which parameters are used to configure the module.
  • 12. <extension type="module“ version="2.5“ client="site“ method="upgrade"> This line tells to Joomla! that selected extension type is module and compatible with Joomla version 2.5. Extension type is also defined for site which means it will be available for front-end.
  • 14. <files> <filename module="mod_reviews">mod_reviews.php</filename> <filename>index.html</filename> <filename>helper.php</filename> <folder>tmpl</folder> <filename>mod_reviews.xml</filename> </files>
  • 15. <?xml version="1.0" encoding="utf-8"?> <install type="module" version="1.5.0"> <name>Hello, World!</name> <author>John Doe</author> <version>1.5.0</version> <description>A simple Hello, World! module.</description> <files> <filename>mod_reviews.xml</filename> <filename module="mod_reviews">mod_reviews.php</filename> <filename>index.html</filename> <filename>helper.php</filename> <filename>tmpl/default.php</filename> <filename>tmpl/index.html</filename> </files> <params> </params> </install>
  • 16. <?php //license details here class modReviewsHelper { /** * Retrieves the reviews * * @param array $params An object containing the module parameters * @access public */ function getReviews( $params ) { return 'I am a happy user!'; } } ?>
  • 17. <html><body bgcolor="#FFFFFF"></body></html> This file is included to prevent directory browsing. It can be event left blank and whenever someone will access the directory then this file will be default loaded.
  • 18. <?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); //print user reviews echo $reviews; ?>
  • 19. <html><body bgcolor="#FFFFFF"></body></html> This file is included to prevent directory browsing. It can be event left blank and whenever someone will access the directory then this file will be default loaded.
  • 20. Once a base module is ready, we can start using it immediately in Joomla.  In Joomla 1.5, it was auto-detected but in Joomla 2.5, we would need to discover a newly developed extension from admin panel.  For this, please login to admin panel and go to Top menu>extensions>extension manager  Click on the discover tab and refresh the data
  • 21.
  • 23. Click on the discover button to find newly developed extensions
  • 24. If your programming is correct, it will find your newly developed extension. Select the extension and click on install button to setup the extension.
  • 25.
  • 26. Once a module is added in the Joomla! System, it has to be defined on a position using module manager.  It will allow module to display in the front-end.
  • 27. Go to module manager and click on “New” button
  • 29. Define module position in active template and set other parameters and pages to display the module. I give it position 6 in Beez_20 template.
  • 30. Module successfully saved, now move to front-end to check this.
  • 32. I can’t see the module ◦ Check if you have selected correct position in the active template
  • 33. With the previous example, you can display one static customer review but what if there are many customer reviews which should be dynamically loaded on the page.  Let’s do that!
  • 34. Using phpMyAdmin or any other DB management tool, create a table called __reviews in the Joomla DB  Add required fields i.e. id, name, city and feedback in the table  Kindly note this example is meant to be very basic for easy understanding
  • 35. Create table and add fields in the database. Note: Ideally, it is the part of component.
  • 36.
  • 37. I have done some entries in the DB directly for the demo purpose. It should happen via a back-end component in real environment.
  • 38. Now, since we are not doing any static code and want to load reviews dynamically from the database, we need to make some changes in below files: ◦ mod_reviews.php – minor change ◦ helper.php – major change for DB connection and query ◦ tmpl/default.php – minor change ◦ tmpl/reviews.php – new template file added
  • 39. <?php //license details here // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); // Include the syndicate functions only once require_once( dirname(__FILE__).DS.'helper.php' ); //load helper class and function //$reviews = modReviewsHelper::getReviews( $params ); $rows = modReviewsHelper::getReviews( $params ); //load the layout file from template views require( JModuleHelper::getLayoutPath( 'mod_reviews' ) ); ?>
  • 40. <?xml version="1.0" encoding="utf-8"?> <extension type="module" version="2.5" client="site" method="upgrade"> <name>Reviews</name> <author>Vishwash Gaur</author> <version>2.5.0</version> <description>An review module.</description> <files> <filename module="mod_reviews">mod_reviews.php</filename> <filename>index.html</filename> <filename>helper.php</filename> <folder>tmpl</folder> <filename>mod_reviews.xml</filename> </files> </extension>
  • 41. <?php //license details here class modReviewsHelper { /** * Retrieves the reviews * * @param array $params An object containing the module parameters * @access public */ function getReviews( $params ) { return 'I am a happy user!'; } } ?>
  • 42. <?php //license details here class modReviewsHelper { /** * Retrieves the reviews * @param array $params An object containing the module parameters * @access public For the demonstration */ function getReviews( $params ) purpose, kindly understand { //return 'I am a happy user!'; and note that Joomla! uses //limit the number of items to load from DB $items = $params->get('items', 10); it’s own code conventions //make DB connection to make DB connections and $db=& JFactory::getDBO(); $result= null; to run a query. It allows in //run db query $query = 'SELECT * FROM #__reviews'; less code and standardized $db->setQuery($query, 0, $items); $rows = $db->loadObjectList(); approach. //display and handle error warning if ($db->getErrorNum()) { JError::raiseWarning( 500, $db->stderr(true) ); } return $rows; }
  • 43. /** * Function to display rating and reviews via views * @param array $params An object containing the module parameters * @access public */ function renderReviews(&$reviews, &$params) { //variable to store db value of a particular record link to open in detailed view $link = JRoute::_('index.php?option=com_reviews&id='.$reviews->id.'&task=view'); //call template view for display require(JModuleHelper::getLayoutPath('mod_reviews' , 'reviews')); } } ?> This component doesn’t exists in the system but we have planned it for future use or next demo of component development.
  • 44. <?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); //print user reviews //echo $reviews; foreach($rows as $row) { modReviewsHelper::renderReviews($row, $params); } ?>
  • 45. <?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); ?> <table width="95%"> <tr><td> <strong><?php echo ucwords(strtolower($reviews->name)); ?></strong> <br /> <span style="font-size:9px; margin-top:-5px;"> <?php echo ucwords(strtolower($reviews->city));?></span><br /> </td> </tr> <tr> <td><?php echo wordwrap($reviews->feedback,130, "<br />n");?></td> </tr> </table>
  • 47. Get your XAMP, LAMP, MAMP or WAMP environment ready  Install and experiment Joomla! Locally  Checkout online references  Get a book  Visit Joomla! JED, Forums and user groups  Help each other and learn from experiences
  • 48. I look forward to learn and share more with you in future too.  I can be reached easily at my blog www.vishwashgaur.com and/or using twitter @vishwashgaur
  • 49. XAMP: http://www.apachefriends.org/en/xampp.html  Joomla!: http://www.joomla.org/  JED: http://extensions.joomla.org/  Joomla! Forum: http://forum.joomla.org/  Joomla! Magazine: http://magazine.joomla.org/authors/itemlist/user/65-Nicholas-G-Antimisiaris  Joomla documentation: http://docs.joomla.org/  Joomla 2.5 essential training: http://www.lynda.com/Joomla-tutorials/Joomla-Essential-Training/95699-2.html  Joomla! For beginners guide 2012: http://www.danconia.com/joomla-for-beginners-guide-2012.html  Joomla! Developers guide: http://cocoate.com/sites/cocoate.com/files/private/jdev.pdf

Notas do Editor

  1. Hi, I am Vishwash Gaur. Today, I am going to present a beginner series webinar on the topic of Component and Module development in Joomla 2.5
  2. There would be an added benefit if you have downloaded, installed and used Joomla! a little bit in prior.In reducing the procedural code issues i.e. lack of code reusability, higher debugging time and more