Creating a Module Disable Position PDF Print E-mail
Written by Administrator   
Saturday, 02 January 2010 05:48
I just read great trick from best of joomla today. Article author is Jonathan Stanley.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:

1.<?php if ($this->countModules('left')): ?>

2.<div id="left"><jdoc:include type="modules" name="left" style="rounded" /></div>

3.<?php endif; ?>

We will make a simple change to disable the module position when a module is assigned to the module disable position:


1.<?php if ($this->countModules('left') && !$this->countModules('x-left')): ?>

2.<div id="left"><jdoc:include type="modules" name="left" style="rounded" /></div>

3.<?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

Author:Jonathan.About Jonathanr: Jonathan Stanley is a website developer and Joomla veteran at Bristlecone Web. Read Original post from author website Here


Administrator Written on Saturday, 02 January 2010 05:48 by Administrator

Viewed 858 times so far.

Rate this article

(1 vote)

Comments (3)Add Comment
Tiap
...
written by Tiap, January 02, 2010
I dont see Line 1 In Index.php. I use JA Urani template
admin
...
written by admin, January 02, 2010
Hi tiap
I think this template dont have left column. Use another position
0
...
written by John.J, January 25, 2010
What a great method !!
Very useful!
Thx for sharing!

Write comment

security code
Write the displayed characters


busy
Last Updated on Saturday, 02 January 2010 06:01
 

Extensions

Tools
+Backup
+Mini tools

+
Advertise
+
SEO &SEF

Media
+
Gallery
+
Video
Styles
+Tab & Slide
+Sharing
+
Tags Cloud
+Visitors
Shop
+
Update
+Update

Articles
+Blogger
+News
+Comments
+Auto post
Social
+
Forums
+ShoutBox

Special
+
Holidays
+Editors

+Files

Manage
+
Download
+Update

+Update

Most downloads in 10 days

calendar.gifAug.01

Today Joomlapanel are pleased to announce the release of  Free JP Dreamland Template, the 5th Te...

calendar.gifMay.20

a free Joomla template for travel

calendar.gifMay.20

A nice templates for Joomla 1.5

calendar.gifMar.16

MyPortfolio Joomla 1.5 template is very first template I ever made for Joomla Community when Port...

calendar.gifApr.06

Free Joomla templates from Templatemonster. It's nice

Extensions stats

The download archive contains currently 139 downloads in 24 categories. To date, these have been downloaded 45267 times.

Blog Tips

Blog News
SEO Tips

Online

We have 60 guests online

Newest Files

calendar.gifMar.01

Latest Free Template From Joomvision

calendar.gifMar.01

Today Joomvision are pleased to announce the release of Free JV 9BodyTemplate

calendar.gifSep.11

The Fastest Joomla! Admin Template AdminPraise Lite is a super lightweight Joomla! administrator ...

calendar.gifAug.15

Hi! JoomPlaza members,today, I received anouncement from Rockettheme. A new free Joomla template ...

calendar.gifAug.01

Today Joomlapanel are pleased to announce the release of  Free JP Dreamland Template, the 5th Te...

SocialTwist Tell-a-Friend