Joomla Template layout help

Hi all,

I am having a bit of difficulty getting my head around joomla templating and wouldelp with this please.

I have created a new template for a site which with a two column layout i.e.

<left Column><right column>

However, I want to add a second layout for selected pages

<single div>

How do I do this? Can I add a second page layout to the template? If so then how do I go about selecting it for the page please?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peter HartCommented:
I assuming you have the latest Joomla?
from what you say I think you mean you have 2 templates?
you upload templates as normal using the extension manager
activate one of them

then there is a couple of ways of doing it , heres one:

then go to the template manager and list/
when you can see the list of templates click on the 'other template' and it will give you a list
of menu assignment for that template click on the menu assignments you want to use the second template.
Steve BinkCommented:
Using a second template as suggested by chilternPC is one option for you.  I'm not sure (still a bit new to Joomla! myself..), but I believe you can only manage the template selection from a menu item.  Generally, that is not a problem, since you can always create hidden or un-published menus to handle that.

Another strategy I used in one site recently:
1) Arbitrarily designate one of your columns as your "main" content column.  It does not matter which one, and this is not a designation within Joomla! - this is just you saying "this other column may not exist on all pages".
2) Make sure any modules appearing in the non-main column are assigned only to pages using the two-column layout.
3) In the template's index.php, use PHP to conditionally print the non-main column only if modules exist for it.  You can check the default templates for examples of how to do this.
4) Use the same PHP conditional concept to write a special class to the "main" column if the non-main does not have any modules
5) Use CSS to target that special class to re-style the main column as appropriate.

The result is that as long as a page has no modules to render inside the column chosen to be your "sidebar", the second column will not be included at all, leaving the entire width open to your "main".  Understand?
flynnyAuthor Commented:
HI all,

Just to clarify I am running Joomla 2.5 (not the latest version).

I have read the Joomla WIKI which seems to suggest I have to create a second theme and then set the relevant pages to use each theme.

I just thought it may be possible to have more than one instance of index.php in the theme layout folder?

Or fo i have to physically have

my theme - single column layout
my theme - two column layout, etc

Apologies if this is extremely basic but as I am new to joomla it seems a bit un-natural to do this. As essentially they would be using the same images, css files just a different .php layout file?
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Peter HartCommented:
as @routine suggested you can have one theme with 2 columns, as long as its all done in CSS and there are no max widths set, when you Don't use a side column it just won't be there.
so if you have a module that displays the latest news in the right hand column, at the bottom of the module's instance you can specify what pages it appears on and those pages where you don't let it write will have an empty column and will not display
see one of my sites using one theme

on the contact page I made sure nothing was writing to the right hand column (position-7 in my case)

and so takes up to whole page.
Steve BinkCommented:
>>> I just thought it may be possible to have more than one instance of index.php
>>> in the theme layout folder?

No, that is not even possible at the file system level - two files with the same name in the same directory.  It is possible to have multiple "styles" (Joomla! term) of a single template, but that is usually concerned with color preferences.  Think of the template as the structure, and the style as the...well, style.

It is possible to use more than one template on a site, but they will need to exist as different templates.  If you intend to share assets between them, then those assets rightfully belong in /images as common assets, not /templates/mytemplate/images as template-specific assets.  Each template should have its own CSS files, though I'm sure there are situations where sharing a common styling is helpful.  In that case, /css, instead of /templates/mytemplate/css.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
flynnyAuthor Commented:
Hi many thanks for all the help.

Ok, I have following code;

            <div class="main">

		<div class="main-top">
			<jdoc:include type="modules" name="main-top"/>
          	<div class="text<?php echo $pageclass ->get('pageclass_sfx'); ?>">
                	<jdoc:include type="component" />
             <?php if ($this->countModules('simplespotlight')): ?>
                <div id="simplespotlight">
                	<jdoc:include type="modules" name="simplespotlight"/>
             <?php endif; ?>        
              <?php if ($this->countModules('banner')): ?>
             <div id="banner">
             <jdoc:include type="modules" name="banner"/>
             <?php endif; ?>

            <div class="footer">
            	<div id="home-footer">
                	<jdoc:include type="modules" name="home-footer"/>

Open in new window

with the following css;

#simplespotlight { float: left; height: 430px; width:485px; margin-left:10px; }
.text{position:relative; margin-top:0px; float: left; width:405px; margin-left:10px;}
.text-article{margin-top:0px; float: left; padding:15px; min-height: 400px;}

Open in new window

So, as you can see (and this does work), I have my left column (text div) and my right column (simplespotlight).

If there is no module added to the simplespotlight div then this is not displayed, and I add the page class prefix to the left column div (basically removing the width style) to give a full width.

however I now have a third party module, where some pages pages in the module need a full width and some do not.  Do you have any ideas how I can handle this?
Steve BinkCommented:
>>> however I now have a third party module, where some pages pages in
>>> the module need a full width and some do not.  Do you have any ideas
>>> how I can handle this?

Can you explain this further?
flynnyAuthor Commented:
Thanks for the help guys.

Just to inform you i basically put a lttle jquery code in the template of the modules to change the css to append the appropriate class required.

a little messy, but it works.

thanks for all the advice.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.