Best of joomla gives you news, joomla templates, extensions, joomla hosting,joomla 3.x templates, tutorials and websites about Joomla , FireBoard official page.
Login | No account yet?  Register | Lost Password?
Best Of Themes

Joomla Resources and Tutorials

Creating a Module Disable Position
SUBMITTER Posted by yourmanstan (1) | 2009-12-18 15:26:08

For years there has been a common situation that is not easily addressed by Joomla: what to do when you want to turn a module off on a single page when you want to leave it as "show on every page". Up until now, the only options we were able to offer our clients is one of the following:

1. Change the modules to only show on specified pages
2. Create a unique template for that page
3. Avoid having pages that are different from the rest of the website

Each of these options has pretty substantial limitations. The first option means that any time a new page is added, someone has to remember to go hunt down modules and assign them to the new pages. This is extremely challenging for websites with hundreds of pages. The second option is fairly time consuming and somewhat burdensome to manage. The last option is obviously not what the client and/or visitor will want. This leaves us with three fairly unacceptable options.

During a recent website design implementation, I had an epiphany of sorts. What if we create a module position that is the opposite of a usual module? Consider a simple template that has the following menu positions:

* header
* left
* right
* footer

We create a custom html module on the left that shows the contact information on every page. However, what if we want one page to turn off the left column and show a full-screen flash piece? The solution is to create a corresponding module disable position: "x-left". We then create a custom html module and title it "TURN OFF LEFT COLUMN" so that administrators will understand what it is. The title and text within the module do not matter so long as they provide sufficient explanation to administrators who may come across them. The module is then assigned to the menu items where we do not want to show the left column. We will then edit the index.php for the template as follows:

Usually the template code would be something like this:
<?php if ($this->countModules('left')): ?>
<div id="left"><jdoc:include type="modules" name="left" style="rounded" /></div>
<?php endif; ?>

We will make a simple change to disable the module position when a module is assigned to the module disable position:
<?php if ($this->countModules('left') && !$this->countModules('x-left')): ?>
<div id="left"><jdoc:include type="modules" name="left" style="rounded" /></div>
<?php endif; ?>

Once this is done, the left column will now be disabled on the individual pages we specify by simply assigning a module to the x-left position for those pages. We can also create corresponding disable positions for each of the other positions:

* x-header
* x-left
* x-right
* x-footer

Since each of the positions begins with "x" they are kept together and at the end of the list (out of the way for the usual changes to the modules). Although this is quite a simple solution and is almost painfully obvious, I haven't seen it used on any major templating sites and it is extremely powerful and useful addition to any Joomla template. After writing this article I have found one alternative method to achieving this goal, however I believe this solution is more graceful, less processing, and does not require a programmer to administer once implemented

About the author: Jonathan Stanley is a website developer and Joomla veteran at Bristlecone Web

Read more ...

Advanced Filter
Best of Joomla! Resources RSS Feed Get the global feed for the news and resources
Shape 5 Joomla Templates
Professional Joomla Templates