RSS Feed

‘joomla’ Category

  1. The one thing you need to know about building CMS themes

    November 10, 2010 by admin

    Does it support intelligent body classes?
    It will make your theming life so much easier, it’s absolutely ridiculous …

    Read about the WordPress version and the benefits of using this concept for theming purposes here: http://codex.wordpress.org/Template_Tags/body_class

    WordPress (2.8+):

    <body <?php body_class(); ?>>

    Drupal (originally from Zen Theme, since Drupal 6 in core):

    <body class="<?php print $body_classes; ?>">

    Joomla:

    Not available by default, must be built manually in template. The Joomla 1.6 version of the default Milkyway template uses something remotely similar for color and background parameters and template width.

    Magento:

    <body <?php echo $this->getBodyClass()?'class="'.$this->getBodyClass().'"':'' ?>>

  2. Write a simple Joomla 1.6 module from scratch

    June 28, 2010 by admin

    Create you first Joomla 1.6 module completely from scratch.

    Joomla, as of version 1.5 which was a complete rewrite is based on the MVC design pattern which makes creating modules extremely easy and structured. Joomla 1.6 changes a few things, the basics however remain the same.

    1. Create a folder called mod_helloworld in modules
    2. Create a mod_helloworld.php file
    3. Create a mod_helloworld.xml file
    4. Create a helper.php file
    5. Create a template file tmpl/default.php
    6. 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 helloworld.xml file

    	<?xml version="1.0" encoding="utf-8"?>
    	<extension type="module" version="1.6.0" client="site" method="upgrade">
    	    <name>Hello World!</name>
    	    <author>Reinhold Weber</author>
    	    <version>1.6.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>