How to specify a home page layout and an article page layout in joomla?

Posted on 2011-02-27
Last Modified: 2012-05-11
I have two layouts, one for the home page and one for article pages.  I have a custom template built and saved as index.php in joomla for the home page, but how do I specify another layout for article pages?
Question by:EMB01
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
LVL 12

Assisted Solution

by:Panagiotis S
Panagiotis S earned 225 total points
ID: 34992845
1. Create homepage conditionals in Joomla!, or create the ability to target the default menu item.

Sometimes it's necessary to specify styling or some functionality that is specific to the front page. Joomla! provides a few different ways to do this. One of them is to place a check for the front page in the template code.

1.// Detecting Home
2.$menu = & JSite::getMenu();
3.if ($menu->getActive() == $menu->getDefault()) {
4.$siteHome = 1;
6.$siteHome = 0;

In this snippet, we're grabbing the menu in the $menu variable, then checking if this menu item is the active menu item and if it's the default. We're then setting a variable $siteHome with a boolean value (1 or 0) i.e. whether the variable returns a true or false value.

Now you can place a simple conditional around any html element in the page:

1.<?php if($siteHome) { ?>
2.<div id="home-banner">
3.This content will only show on the homepage!
5.<?php } ?>

from joomla magazine
LVL 13

Accepted Solution

joomla_php earned 275 total points
ID: 34993021
It should be the same in 16 as it is in 15, if not report back here

install both templates, each having a distinct name

Under extensions, templates,
click template1, assign it to the home page, save
click template2, assign it to all other pages, save
LVL 14

Author Comment

ID: 34993211
Okay, so I have two options:  1.  add conditionals to the template.  2.  create another template all together.

One small, additional question:  How do I echo the meta description in my template?  For instance:

<h1><?php echo_joomla_title(); ?></h1>
<h2><?php echo_joomla_meta_description(); ?></h2>
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 13

Expert Comment

ID: 34993276
The meta description is output via the use of

<jdoc:include type="head" />
LVL 14

Author Comment

ID: 34993301
That sounds like it outputs more than just the description.  Is there anyway to get just the description?  Or, is it impossible?
LVL 13

Expert Comment

ID: 34993507
echo ($this->getMetaData('keywords'));
echo ($this->getMetaData('description'));
LVL 12

Assisted Solution

by:Panagiotis S
Panagiotis S earned 225 total points
ID: 34994610
the easiest method is the one with the simple conditions.

The only need is to have some additional css classes for the home page

LVL 14

Author Closing Comment

ID: 34997022
I think I would like to create two different templates, rather than using conditionals.  Thanks for the extra info.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Joomla Articles with PDF 2 268
Joomla 1 195
MAMP Pro/Joomla3 account creations fails 6 82
How to retrieve saved $session data under Joomla 3.x with different SessionID 7 247
Here is a tutorial for making your own Joomla templates. Note before reading, you should have some existing knowledge of web development using HTML and CSS. Design Layout: Design your template in a graphics program like Adobe PhotoShop or Corel…
First of all, we will need Jumi component or Sourcerer plugin for this to work. We need either of these because the main focus here is custom development outside of the standard modules or articles within Joomla. You can find Jumi's my …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question