Joomla! with Flash: Flashy Templates, Headers, Banners, and Tickers: Part 1

Suhreed Sarkar

November 2009

In this article, we will mainly focus on the visual design of our site. To acquire the information presented here, it is assumed that you have some basic understanding of Joomla!'s visual design including templates, components, module position, and so on.

Adding Flash in templates

If you are familiar with Joomla! templates, then you will understand that there are two ways to display Flash in a template:

  • By hardcoded embedding of Flash items
  • By dynamically loading Flash objects at module positions

We have seen many modules that can display Flash objects. Therefore, in this section, we will be looking into the embedding of Flash objects within templates. It will also be helpful if we understand the structure of Joomla! templates.

Generally templates for Joomla! include headers in Flash. Flash animations are included in the header area of a Joomla! template. Some templates include the mechanism to show images from a specific directory. For example, the template shown in the following screenshot, available for download at, is designed to show a Flash header comprised of the images kept in a directory:

Joomla! with Flash

The following sections briefly describe the structure of a Joomla! template and the ways to embed a Flash object in this template.

Structure of a Joomla! template

The look and feel of Joomla! is determined by templates. You can apply a template to the frontend as well as to the backend. Templates for the Joomla! frontend reside in the /templates directory of the Joomla! webroot, while those for the administration panel are found in the /administrator/templates directory. You can install multiple templates and apply one or more templates to the different sections. However, you must designate one default template for the site.

To designate a default template, go to Extensions | Template Manager. Select the desired template and click on the Default button on the toolbar. For assigning a template to a specific section of the site, click on a template, except the default template, and then select the section or the menu item for which you want to assign the template from the Menu Assignment section.

If you examine the directory structure of a Joomla! template, you will find at least the following subdirectories in the templates directory:




This is the main template directory. It contains some subdirectories and at least the following files under its root:

  • index.php: This is the main file for a template. The basic structure of a Joomla! template is defined in this file. We will examine this file later.
  • templateDetails.xml: This XML file defines the template by mentioning its designer, the different files bundled with it, the positions and parameters available, and so on.
  • params.ini: This file contains the parameters and their default values. For example, a template may use several colors for theming, but users can select a preferred color as a parameter for this template, and that information is stored in this file.


This directory contains all the cascading stylesheets to be used for a Joomla! site. This directory will contain at least one stylesheet named template_css.css. It may also contain a stylesheet named template_ie6.css and other stylesheets.


This folder may contain some definitions for the custom rendering of certain parts of the site. For example, the mx_joofree2 template contains two files-module.php and pagination.php. These two files define custom module rendering and pagination for Joomla!. For more information on using HTML overrides, refer to!_core.


This folder contains the images for the template. It may contain a logo image, a background image, and so on. It may also contain some subdirectories, for example, the mx_joofree2 template contains a subdirectory images/headers, where the header images for the template are stored.

As you know, the main structure of a Joomla! template is defined in the index.php file. The file looks as follows:

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

This line of code is to prevent direct access to the file. This is a convention to prevent direct access to any file in Joomla!. After this, the following lines define some variables for the template that will be used later on in the template:

define( 'YOURBASEPATH', dirname(__FILE__) ); 
$live_site = $mainframe->getCfg('live_site');
$template_path = $this->baseurl . '/templates/' . $this->template;
$show_flashheader = ($this->params->get("showFlashheader", 1) == 0)?"false":"true";
$show_logo = ($this->params->get("showLogo", 1) == 0)?"false":"true";
$show_date = ($this->params->get("showDate", 1) == 0)?"false":"true";
$show_breadcrumbs = ($this->params->get("showBreadcrumbs", 1) == 0)?"false":"true";

Having defined the template variables, the template's structure starts with some common HTML declarations as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang=
"<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >

Whatever is included after the following lines will be considered as included in the <head> section. Generally, stylesheets, JavaScript, and site-wide files are included in a template's <head> section with the following lines:

<jdoc:include type="head" /> 
<link rel="shortcut icon" href=
"<?php echo $this->baseurl; ?>/images/ favicon.ico" />
<link href="<?php echo $this->baseurl ?>/templates/system/ css/system.css"
rel="stylesheet" type="text/css" />
<link href="<?php echo $this->baseurl ?>/templates/system/css/general. css"
rel="stylesheet" type="text/css" />
<link href="<?php echo $this->baseurl; ?>/templates/<?php echo $this->
template?>/css/template_css.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="templates/<?php echo $this->
template ?> /css/ie6.css" type="text/css" />

If you have read this article you may be interested to view :

Next, the body section of the template starts:

<body class="body_bg"> 
<div id="bgr">
<div id="wrapper">
<div id="tophead">

The following block checks whether any module for position user4 is enabled. If the count of enabled modules is greater than zero, then a <div>element with an ID search is displayed, and modules specified for position user4 are displayed as children of this <div> element:

<?php if($this->countModules('user4')) : ?> 
<div id="search">
<jdoc:include type="modules" name="user4" style="xhtml" />
<?php endif; ?>

Having placed the modules for the position user4, the following block now defines where to show the site's logo. This block of code dynamically selects the site's logo and links that to the site's home page:

<!-- BEGIN: LOGO --> 
<?php if($show_logo == "true") : ?>
<div id="logo">
<a href="<?php echo $mosConfig_live_site;?>">
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->
template?>/images/logo.png" alt="" />
<?php endif; ?>
<!-- END: LOGO -->

If we want to show a Flash header beside the logo, then we can add the following block to include a Flash object:

<!-- BEGIN: flashheader --> 
<?php if($show_flashheader == "true") : ?>
<div id="ol-flashheader">
<object type="application/x-shockwave-flash" data="<?php echo $this->
baseurl; ?>/templates/<?php echo
$this->template?>/ images/header.swf " width="700" height="240">
<param name="wmode" value="transparent" />
<param name="movie" value="<?php echo $this->baseurl; ?>/templates/
<?php echo $this->template?>/images/header.swf" />
<?php endif; ?>
<!-- END: flashheader -->

This code block first checks whether the variable for showing a Flash header is checked or not. If it is checked, then a  <div> element will be created, under which the Flash object is embedded using the <object> </object> tags.

The following code block is used to display the current date on the site:

<!-- BEGIN: Date --> 
<?php if($show_date == "true") : ?>
<div id="date-format">
<?php $now = &JFactory::getDate(); echo $now->toFormat("%A, %d %b %Y"); ?>
<?php endif; ?>
<!-- END: Date -->

The following block defines another module position. Modules designated for the user3 position will be displayed here. Note that modules are included with the <jdoc:include type="modules" name="position-name" /> markup:

<?php if( $this->countModules('user3') ) {?> 
<div id="topcol">
<div id="topmenu">
<table cellspacing="0" cellpadding="0" style="float: left;">
<jdoc:include type="modules" name="user3" />
<?php } ?>
<div id="wrapper_2">
<div id="holder">

The following code block displays another module called breadcrumbs. First, it checks whether the parameter is set to show breadcrumbs or not. If it is, then the breadcrumbs module will be displayed in the block:

<!--pathway start--> 
<?php if ($show_breadcrumbs == "true") : ?>
<div class="path">
You are here: <jdoc:include type="module" name="breadcrumbs"/>
<?php endif; ?>
<!--pathway end-->

Next comes the module for the left position:

<div id="content"> 
<?php if($this->countModules('left') and
JRequest::getCmd('layout') != 'form') : ?>
<div id="left">
<jdoc:include type="modules" name="left" style="rounded" />
<?php endif; ?>

The following block includes the modules designated for the right position:

<?php if($this->countModules('right') and
JRequest::getCmd('layout') != 'form') : ?>
<div id="main">
<?php else: ?>
<div id="main_full">
<?php endif; ?>
<div class="nopad">
<jdoc:include type="message" />

The next code block counts the number of modules available for the user1 and user2 positions and then includes the modules designated for these two positions. Note the highlighted line of code in this code block. It shows the component currently selected:

<div id="lr-padd">
<table class="lr-padd" cellspacing="2">
<tr valign="top">
<?php if( $this->countModules('user1') ) {?>
<td class="lr-padd">
<jdoc:include type="modules" name="user2" style="xhtml" />
<?php } ?>
<?php if( $this->countModules('user1') ) {?>
<td class="lr-padd">
<jdoc:include type="modules" name="user2" style="xhtml" />
<?php } ?>
<jdoc:include type="component" />
<?php if($this->countModules('right') and
 JRequest::getCmd('layout') != 'form') : ?>
<div id="right">
<jdoc:include type="modules" name="right" style="rounded" />
<?php endif; ?>
<div class="clr"></div>

Finally, here comes the footer section. The highlighted line in the following code block includes a footer file to show the footer text:

<!--footer start--> 
<div id="footer">
<div id="footer_in">
<div style="text-align: center; padding: 18px 0 0;">
<?php include (dirname(__FILE__).DS.'/footer.php');?>
<!--footer end-->
<jdoc:include type="modules" name="debug" />

All this code in the index.php file when rendered with template_css.css and other stylesheets will display a layout like the one shown in the following screenshot:

Joomla! with Flash

In a Joomla! template, the site's data comes from the database and fits in different positions. When you are planning for Flash-based Joomla! templates, you should first identify where to put the Flash objects and where to display the dynamic data for the site. In the template layout, we have seen that a suitable place for adding a Flash object are the logo and the header positions. We can also use some extensions to display Flash headers. The following sections explain how to use extensions for showing Flash logos and headers.

Using Flash logos

You can replace the ordinary image with Flash-animated logos by embedding it in that position. As we have seen earlier, Flash objects are embedded in Joomla! templates using the <object> </object>XHTML element. For styling purposes, you may put this element under a <div> element, as shown in the following code:

<div id="logo"> 
<object type="application/x-shockwave-flash" data=
"/templates/mx_joofree2/images/logo.swf" width="200" height="200">
<param name="movie" value="/templates/mx_joofree2/images/logo.swf">

As you can see, the <object> </object> tag can contain child elements. We pass parameters to the Flash objects using the <param> element. For example, we have passed the name of a movie file using the highlighted tag in the previous code.

Some of you may already know about the SWFObject JavaScript library. It is used to embed Flash files using JavaScript. You can also use it to embed Flash objects in Joomla! and can also generate Flash objects. It is freely available at Brief documentation on its usage is also available there.

>> Continue Reading: Joomla! with Flash—Flashy Templates, Headers, Banners, and Tickers: Part2

If you have read this article you may be interested to view :

You've been reading and excerpt of:

Joomla! with Flash

Explore Title
comments powered by Disqus