The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Sep 02, 2011 7:41 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Sep 02, 2011 2:56 pm
Posts: 7
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:
<?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:
$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


Top
 Profile  
 
PostPosted: Sat Sep 03, 2011 6:19 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sun Oct 18, 2009 4:59 pm
Posts: 639
Location: India
This might work. I have not tested yet. You can try and let me know.

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

_________________
Sweta Ray
PHP Developer
http://www.phpseo.net
http://www.sitepayment.com


Top
 Profile  
 
PostPosted: Sat Sep 03, 2011 6:31 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Sep 02, 2011 2:56 pm
Posts: 7
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:
 $this->_basewidth = 30;


Please suggest.
Thanks
Dipak


Top
 Profile  
 
PostPosted: Sat Sep 03, 2011 6:37 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Sep 02, 2011 2:56 pm
Posts: 7
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


Top
 Profile  
 
PostPosted: Sat Sep 03, 2011 8:00 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sun Oct 18, 2009 4:59 pm
Posts: 639
Location: India
change
$fronturl= $mainframe->getCfg('live_site'); to
$fronturl = JFactory::getApplication()->getCfg('live_site');

_________________
Sweta Ray
PHP Developer
http://www.phpseo.net
http://www.sitepayment.com


Top
 Profile  
 
PostPosted: Sat Sep 03, 2011 8:15 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Sep 02, 2011 2:56 pm
Posts: 7
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


Top
 Profile  
 
PostPosted: Sat Sep 03, 2011 10:43 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sun Oct 18, 2009 4:59 pm
Posts: 639
Location: India
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.

_________________
Sweta Ray
PHP Developer
http://www.phpseo.net
http://www.sitepayment.com


Top
 Profile  
 
PostPosted: Thu Apr 05, 2012 7:54 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Apr 05, 2012 7:46 am
Posts: 1
I've done search and end up here. Any method success doing as he asking?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 



Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group