How to have layout for front page and other pages different?

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
dipaksaraf
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Fri Sep 02, 2011 2:56 pm

How to have layout for front page and other pages different?

Post by dipaksaraf » Fri Sep 02, 2011 7:41 pm

Hello

In order to have a layout according to our choice we create a layout file in the template folder which form the basis for placing different module. Now I have requirement in which the home page or front page as it is referred in Joomla Template there will be a left and right placeholder of equal width i.e 50%, but the left and right for other pages will be 70%, 30%.

The coding in the present template supports 70%, 30% for all the pages including frontpage.

Code: Select all

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$this->_basewidth = 30;
$positions = array (
	'left1'					=>'',
	'left2'					=>'',
	'left-mass-top'			=>'',
	'left-mass-bottom'		=>'',
	'right1'				=>'',
	'right2'				=>'right',
	'right-mass-top'		=>'',
	'right-mass-bottom'		=>'',
	'content-mass-top'		=>'content-mass',
	'content-mass-bottom'	=>'',
	'content-top'			=>'',
	'content-bottom'		=>'',
	'inset1'				=>'',
	'inset2'				=>'left'
);
$this->customwidth('inset2', 25); //<== override right1 column width to 25%. Must call before call definePosition. Can call many time to override many columns.
$this->definePosition ($positions);
?>
How do i makes changes in the code so that the frontpage will be 50% for left and right position, but will be 70% for left and 30% for right in other pages. if i make changes in the following codes I am able to makes the width 50% for all the pages,not sure what changes to be done in order to accomplish the requirement.

Code: Select all

$this->_basewidth = 30;  //if i change here from 30 to 50, the width changes to 50 for all pages
I want that frontpage will have 50% width left and right respectively whereas the other pages will have the width of 70%, 30% for left and right respectively.

Please Help....

Thanks
Dipak

User avatar
amitray
Joomla! Guru
Joomla! Guru
Posts: 644
Joined: Sun Oct 18, 2009 4:59 pm
Location: India
Contact:

Re: How to have layout for front page and other pages differ

Post by amitray » Sat Sep 03, 2011 6:19 am

This might work. I have not tested yet. You can try and let me know.

Code: Select all

<?php 
$anyurl = $_SERVER['REQUEST_URI'];
$fronturl= $mainframe->getCfg('live_site');
if($anyurl==$fronturl)
$this->_basewidth = 50;
else
$this->_basewidth = 30;
?>

dipaksaraf
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Fri Sep 02, 2011 2:56 pm

Re: How to have layout for front page and other pages differ

Post by dipaksaraf » Sat Sep 03, 2011 6:31 am

Hi Urmila

Thanks for the suggestion. I want to know where should I put this code. I should put this code in the default.php file right before the

Code: Select all

 $this->_basewidth = 30; 
Please suggest.
Thanks
Dipak

dipaksaraf
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Fri Sep 02, 2011 2:56 pm

Re: How to have layout for front page and other pages differ

Post by dipaksaraf » Sat Sep 03, 2011 6:37 am

Hi

I have tried with the code you have suggested, but ran into following problem

Fatal error: Call to a member function getCfg() on a non-object in /home/domain.com/public_html/templates/template_name/layouts/default.php on line 18

Please suggest.

Thanks
Dipak

User avatar
amitray
Joomla! Guru
Joomla! Guru
Posts: 644
Joined: Sun Oct 18, 2009 4:59 pm
Location: India
Contact:

Re: How to have layout for front page and other pages differ

Post by amitray » Sat Sep 03, 2011 8:00 am

change
$fronturl= $mainframe->getCfg('live_site'); to
$fronturl = JFactory::getApplication()->getCfg('live_site');

dipaksaraf
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Fri Sep 02, 2011 2:56 pm

Re: How to have layout for front page and other pages differ

Post by dipaksaraf » Sat Sep 03, 2011 8:15 am

Hi

I have changed the code as suggest,Now the error has gone but the output is same, no effect on the output. The output was suppose to be 50% for left and right but it's still showing 70%. 30%. Any ideas?

Thanks
Dipak

User avatar
amitray
Joomla! Guru
Joomla! Guru
Posts: 644
Joined: Sun Oct 18, 2009 4:59 pm
Location: India
Contact:

Re: How to have layout for front page and other pages differ

Post by amitray » Sat Sep 03, 2011 10:43 am

Try echoing $fronturl and $anyurl somewhere below the page. Check both the values. If it returns integer try to put three "===" sign for comparing strings else you can also use strcmp() a builtin function.

peachy23bus01
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Apr 05, 2012 7:46 am

Re: How to have layout for front page and other pages differ

Post by peachy23bus01 » Thu Apr 05, 2012 7:54 am

I've done search and end up here. Any method success doing as he asking?


Locked

Return to “Templates for Joomla! 1.5”