Solved

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

Posted on 2011-02-27
8
867 Views
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?
0
Comment
Question by:EMB01
  • 3
  • 3
  • 2
8 Comments
 
LVL 12

Assisted Solution

by:panagiotiss
panagiotiss earned 225 total points
Comment Utility
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;
5.}else{
6.$siteHome = 0;
7.}

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!
4.</div>
5.<?php } ?>


from joomla magazine
0
 
LVL 13

Accepted Solution

by:
joomla_php earned 275 total points
Comment Utility
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
0
 
LVL 14

Author Comment

by:EMB01
Comment Utility
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>
0
 
LVL 13

Expert Comment

by:joomla_php
Comment Utility
The meta description is output via the use of

<jdoc:include type="head" />
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 14

Author Comment

by:EMB01
Comment Utility
That sounds like it outputs more than just the description.  Is there anyway to get just the description?  Or, is it impossible?
0
 
LVL 13

Expert Comment

by:joomla_php
Comment Utility
echo ($this->getMetaData('keywords'));
echo ($this->getMetaData('description'));
0
 
LVL 12

Assisted Solution

by:panagiotiss
panagiotiss earned 225 total points
Comment Utility
the easiest method is the one with the simple conditions.

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

0
 
LVL 14

Author Closing Comment

by:EMB01
Comment Utility
I think I would like to create two different templates, rather than using conditionals.  Thanks for the extra info.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Welcome Friends, This is the tutorial for how to create new simple module in joomla 1.5. In the module has two important files. One is XML file and another file is PHP controller file. First you need to create the XML file. (CODE) …
This is our step by step to setting up and configuring a Joomla Install on a Windows 2003 Server. This is the perfect solution for an Intranet Website using Joomla. What you need (only use the following versions) : A fresh copy of Joomla http…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now