how to hide the Main Body in 1.5 ??

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.
User avatar
dayone
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu Apr 12, 2007 1:18 pm

how to hide the Main Body in 1.5 ??

Post by dayone » Fri Sep 05, 2008 3:31 am

I would like to have modules only display on the frontpage of my site
how can I hide the main body ? and where exactly would I place the code ?
( I don't have much php or coding knowledge )
Thanx in advance

ksorbo
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Wed Apr 11, 2007 2:06 pm

Re: how to hide the Main Body in 1.5 ??

Post by ksorbo » Fri Sep 05, 2008 7:20 pm

There is a way to control display of modules on different pages, but not for the component content. However, I can think of 2 ways to accomplish what you want, both require some editing of the index.php file in the template :(

1. Use 2 templates. Assign the one with the component content tag present (<jdoc:include type="component" /> ) for use on all but the home page. Then reinstall the same template, but edit the template to remove this line from the index.php file. This would be the template to be used on only the home page.

2. Add a conditional statement in the index.php file of your template to test if this is the home page. If it is, don't show the <jdoc:include type="component" /> line, otherwise. Show.

Sadly, both require some work in php.

xpozay
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Oct 31, 2007 7:19 pm
Location: Singapore

Re: how to hide the Main Body in 1.5 ??

Post by xpozay » Sat Sep 13, 2008 8:42 am

I have done this by creating empty "landing pages" which contain only loadpositions for the modules. The articles assigned to the section/category have no other content and have all parameters set to hide. Additionally, different templates can be assigned to give the desired look. This didnt require any php code.

If there are other ways, I would like to know too :)

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Mon Sep 15, 2008 3:02 am

Hello,

What you can do is edit the index.php file of your template. After the check for _JEXEC define add the following code:

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );
$pageview = JRequest::getVar('view', '');
Now find where the main body content is loaded in the template, look for the following line of code: <jdoc:include type="component" style="xhtml" />
Change it to have this if statement around it.

Code: Select all

<?php if ($pageview != 'frontpage') : ?>
          <jdoc:include type="component" style="xhtml" />
<?php endif; ?>
What this does is check if the user is on the home/frontpage and if they are, the body component is not loaded. If the user is on another page, then the body component is loaded.

There are other variables that you can use in your template for checking what type of page you are on and modifying your template based on that information. This is a very powerful way of making your template operate the way that you need without the need to make multiple templates for each special case.
Here are the other variables that might be useful:
$pageoption = JRequest::getVar('option', '');
$pageitemid = JRequest::getVar('Itemid', '');

Good luck
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

User avatar
rw1
Joomla! Guru
Joomla! Guru
Posts: 958
Joined: Sun Aug 28, 2005 11:23 am
Location: New York

Re: how to hide the Main Body in 1.5 ??

Post by rw1 » Mon Sep 29, 2008 6:35 am

ljk wrote:Hello,

What you can do is edit the index.php file of your template. After the check for _JEXEC define add the following code:

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );
$pageview = JRequest::getVar('view', '');
.....
Thanks VERY much ljk, i implemented this along with a collapsing div's solution (documented in this post) and it worked perfectly - thank you!!!

User avatar
davide.taddei
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Tue Jan 22, 2008 8:01 pm
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by davide.taddei » Mon Sep 29, 2008 9:00 pm

Alternative way without writing code: place a html/com_content/frontpage/default.php file in the TEMPLATE root, the default.php file should be empty so no content will appear. You can use it also to hide CATEGORIES, SECTIONS, etc... read more in the article: http://docs.joomla.org/Understanding_Output_Overrides.

It's also useful if you want to place a splash screen with flash ;)

gmopinillosv
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Oct 05, 2008 2:53 am

Re: how to hide the Main Body in 1.5 ??

Post by gmopinillosv » Sun Oct 12, 2008 12:22 am

Hi Davide.taddei
You wrote:
"Alternative way without writing code: place a html/com_content/frontpage/default.php file in the TEMPLATE root, the default.php file should be empty so no content will appear. You can use it also to hide CATEGORIES, SECTIONS, etc... read more in the article: http://docs.joomla.org/Understanding_Output_Overrides.

It's also useful if you want to place a splash screen with flash ...."

But , TEMPLATE root dont have default.php file only have index.php. I read all you recomendation, but I dont got it.

Where exactly place that file. Once placed I can modify that file. That is correct?

Thanks anticipate.

User avatar
davide.taddei
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Tue Jan 22, 2008 8:01 pm
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by davide.taddei » Mon Oct 13, 2008 9:10 am

Well, as explained in the tutorial you should place it in TEMPLATEROOT/html/com_content/frontpage/default.php to override the home page content.

For an example you can take a look to BEEZ template.

This overrides only the content displayed by the component with the code: <jdoc:include type="components" />

If you want to hide other parts you can include CSS that hides them, the file wouldn't be lighter but you don't have to write any line of PHP code.

gmopinillosv
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Oct 05, 2008 2:53 am

Re: how to hide the Main Body in 1.5 ??

Post by gmopinillosv » Mon Oct 13, 2008 3:47 pm

Thanks you for answer.
My confusion was that I sought into /templates/ and isn't there. It is was into /componets/.
I alredy achieve to do it. I am sorry but I am new in that.
A question last : How I fill top menu horizontal for link other URL's ?

Thanks again

gmopinillosv
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Oct 05, 2008 2:53 am

Re: how to hide the Main Body in 1.5 ??

Post by gmopinillosv » Mon Oct 13, 2008 4:54 pm

Don't worry .

I got it !

Thanks you

foe
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Nov 30, 2008 11:26 am

Re: how to hide the Main Body in 1.5 ??

Post by foe » Sun Nov 30, 2008 11:34 am

Menus > Mainmenu* > Home > Base Options = all sets by 0

and ABRAKADABRA!
aa.JPG
You do not have the required permissions to view the files attached to this post.

User avatar
urko99
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jul 14, 2008 6:44 am

Re: how to hide the Main Body in 1.5 ??

Post by urko99 » Sat Jan 24, 2009 11:13 pm

ljk wrote:Hello,

What you can do is edit the index.php file of your template. After the check for _JEXEC define add the following code:

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );
$pageview = JRequest::getVar('view', '');
...
Thanks! Works perfectly. :D

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Tue Aug 04, 2009 6:50 pm

ljk wrote:Hello,

What you can do is edit the index.php file of your template. After the check for _JEXEC define add the following code:

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );
$pageview = JRequest::getVar('view', '');
Now find where the main body content is loaded in the template, look for the following line of code: <jdoc:include type="component" style="xhtml" />
Change it to have this if statement around it.

Code: Select all

<?php if ($pageview != 'frontpage') : ?>
          <jdoc:include type="component" style="xhtml" />
<?php endif; ?>
What this does is check if the user is on the home/frontpage and if they are, the body component is not loaded. If the user is on another page, then the body component is loaded.

There are other variables that you can use in your template for checking what type of page you are on and modifying your template based on that information. This is a very powerful way of making your template operate the way that you need without the need to make multiple templates for each special case.
Here are the other variables that might be useful:
$pageoption = JRequest::getVar('option', '');
$pageitemid = JRequest::getVar('Itemid', '');

Good luck
I've tried this and can't get it to work. I also tried a variation of it that I found elsewhere:

Code: Select all

  <jdoc:include type="message" />
    <?php if ($pageview == 'frontpage') : ?>
         <jdoc:include type="modules" name="custom_html" style="xhtml" />
    <?php elseif ($pageview != 'frontpage')  : ?>
         <jdoc:include type="component" />
     <?php endif; ?>


My site is http://www.tantomedia.com/friendsfirst2. The big blank white area on the front page is what I want to get rid of.

I would LOVE any help you can offer!!!!!

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Wed Aug 05, 2009 3:45 am

I think what's happening is that the content component is being hidden on the front page, but I'm still showing background things, ie, rounded corners, margins, etc.
I can reduce the min height in the css, but the margins will still show and I don't want to remove them...

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Wed Aug 05, 2009 6:19 pm

Hello,

You can change the css for just the frontpage and remove the margin for it. Use the same sort of code, check if you are on the frontpage and if you are then set the margin to 0 for the required css classes and ids. Do this in the head of your index.php file of your template.

Cheers.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Sun Aug 09, 2009 6:34 pm

Thanx ljk!

Can I call css things in the code itself or do I have to create another .css file and call that in the code?
Also, I have no idea what the code would look like, beyond of course:

Code: Select all

<?php if ($pageview != 'frontpage') : ?>
call up the new css things
<?php endif; ?>
Any help you could give would be very seriously appreciated. :D

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Sun Aug 09, 2009 8:04 pm

Hello,

In the head section of your index.php you can add something like the following:

Code: Select all

<style type="text/css" media="screen">
/*<![CDATA[*/
	if ($pageview == 'frontpage') {
		echo ("
			#header {
				height:189px;
				padding:0;
			} 
                       .other_style { css styles here }
		");
	}
?>
/*]]>*/
</style>
Just add the css changes that you want for the frontpage.

Cheers.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Mon Aug 10, 2009 7:57 pm

Thanx! Worked like a charm!

It seems like this something similar to this would work to change the site's background given a certain section, category, or menu id.

something like:

Code: Select all

<style type="text/css" media="screen">
/*<![CDATA[*/
   if ($pageview == 'some category ID') {
      echo ("
         #background {
            background: url...
         }
                       
      ");
   }
?>
/*]]>*/
</style>
But again I don't know the particulars of coding - ie, how to identify the category ID, or menu ID, etc.
Can you help here as well???

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Tue Aug 11, 2009 3:07 pm

maybe something like this??

Code: Select all

<style type="text/css" media="screen">
/*<![CDATA[*/
   if ($pageview == 'com_content&view=category&id=35') {
      echo ("
         #background {
            background: url...
         }
                       
      ");
   }
?>
/*]]>*/
</style>

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Tue Aug 11, 2009 5:30 pm

Hello,

You are on the right track but not quite the correct implementation.

You need to get different parts of the URL to use the menu ID or category ID. Here are some common variables that are used:

Code: Select all

	$pageoption = JRequest::getVar('option', '');
	$pageview = JRequest::getVar('view', '');
	$pageid = JRequest::getVar('id', '');
	$pageitemid = JRequest::getVar('Itemid', '');
Now if you want to change something on a particular menu item, say the menu item has a ItemId of 20, then you would use:

Code: Select all

<style type="text/css" media="screen">
/*<![CDATA[*/
   if ($pageitemid == '20') {
      echo ("
         #background {
            background: url...
         }
                       
      ");
   }
?>
/*]]>*/
</style>
To check for a section or category it is a little more involved as to what you have to do. In this example below I needed to get the section so I could do something special for a particular section (4):

Code: Select all

	$sec = 0;
	if ($pageview == 'section') {
		$sec = $pageid;
	} else if ($pageview == 'category') {
		$db = & JFactory::getDBO();
		$query = "SELECT section FROM #__categories WHERE id = " .$pageid;
		$db->setQuery( $query );
		$sec = $db->loadResult();
	} else if ($pageview == 'article') {
		$db = & JFactory::getDBO();
		$query = "SELECT sectionid FROM #__content WHERE id = ".$pageid;
		$db->setQuery( $query );
		$sec = $db->loadResult();
	}
       if ($sec == 4) {
                // Do whatever you want for the section number 4
       }
You would need to do something similar to get the category.

Hope that helps.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Fri Aug 28, 2009 6:37 pm

Hi ljk - worked great!
A couple of things i had probs with though -
I couldn't get it to function for categories - tried a few things including this:

Code: Select all

$cat=0
<?php if ($pageview == 'category') {
      $cat = $pageid;
   } else if ($pageview == 'article') {
      $db = & JFactory::getDBO();
      $query = "SELECT sectionid FROM #__content WHERE id = ".$pageid;
      $db->setQuery( $query );
      $sec = $db->loadResult();
   }
?>
but couldn't get it to work -

I need to load css files and tried this

Code: Select all

<?php if ($sec == 8){  ?>
             <link rel="stylesheet" href="http://www.tantomedia.com/friendsfirst2/templates/yoo_blueprint/css/green/green-layout.css" type="text/css" /> 
<?php } ?>
But couldn't get this to work either

Any thoughts?

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Sun Aug 30, 2009 1:27 am

Actually,
I can make this work just using sections and not categories.
But, I've been all over the place trying to figure out how to call a .css file within php code and can't get anything to work. I'll definitely keep looking, but if there's any light you can shed on this, or if you can point me in the right direction, I would greatly appreciate it!!!!
Thanx
Mark

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Sun Aug 30, 2009 4:37 pm

Hi,

How about this in the <head> of your document:

Code: Select all

<?php if (condition) { ?>
 	<link href="/templates/<?php echo $this->template; ?>/css/sheet.css" rel="stylesheet" type="text/css" />
<?php } ?>
where condition is the condition for including the style sheet and sheet.css is the style sheet you want to call.

Cheers.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Tue Sep 01, 2009 9:27 pm

Wow, that was it!
I think I'm almost there. The only prob with this is that it doesn't apply the stylesheet for sub menu links that are linked directly to components. I was able to fix that with $pageitemid and simply plug in the itemid from the link, but then I end up with bulky code. Can you help me consolidate this? I've been on several forums re php syntax but can't find anything that works.

Here's my code as it is now.

Code: Select all

<?php if ($sec == 13) { ?>
  <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/SNC.css" type="text/css" />
<?php } ?>
<?php if ($pageitemid == 194) { ?>
  <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/SNC.css" type="text/css" />
<?php } ?>
<?php if ($pageitemid == 207) { ?>
  <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/SNC.css" type="text/css" />
<?php } ?>
<?php if ($pageitemid == 501) { ?>
  <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/SNC.css" type="text/css" />
<?php } ?>
Yuck. And I have two other sections that will need the same code...

Thanx again ljk!!!

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Tue Sep 01, 2009 9:40 pm

Nevermind... looked a little harder

Code: Select all

<?php if ($sec == 13 OR $pageitemid == 194 OR $pageitemid == 207 OR $pageitemid == 501) { ?>
  <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/SNC.css" type="text/css" />
<?php } ?>
I'm sure the pageitemid's could be consolidated in a more sexy way but this is good enough for me.

But I'm curious now - I've monkeyed around with getting this to work with specific categories but couldn't do it. For future reference could I infringe on you one "last" time???

Either way, you've helped a TON here - much appreciated!!!

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Wed Sep 02, 2009 2:27 am

Hi,

If you do a search, I have provided the code to look for a particular category and do something when found. Search isn't working for me right now. So, if you can't find it, send another post and I will post the code again.

Cheers.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

propheus
I've been banned!
Posts: 3
Joined: Tue Jan 10, 2006 12:20 pm

Re: how to hide the Main Body in 1.5 ??

Post by propheus » Fri Sep 11, 2009 12:05 pm

ljk wrote:Hello,

What you can do is edit the index.php file of your template. After the check for _JEXEC define add the following code:

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );
$pageview = JRequest::getVar('view', '');
Now find where the main body content is loaded in the template, look for the following line of code: <jdoc:include type="component" style="xhtml" />
Change it to have this if statement around it.

Code: Select all

<?php if ($pageview != 'frontpage') : ?>
          <jdoc:include type="component" style="xhtml" />
<?php endif; ?>
What this does is check if the user is on the home/frontpage and if they are, the body component is not loaded. If the user is on another page, then the body component is loaded.

There are other variables that you can use in your template for checking what type of page you are on and modifying your template based on that information. This is a very powerful way of making your template operate the way that you need without the need to make multiple templates for each special case.
Here are the other variables that might be useful:
$pageoption = JRequest::getVar('option', '');
$pageitemid = JRequest::getVar('Itemid', '');

Good luck
Hello i use your postet code to hide the mainbody on frontpage. Now i have one problem.
The problem:
The result message from login module can not loaded now cause they are shown on frontpage....
Example:
I try to login with wrong pw. Then joomla put out something like that "Username and password do not match or you do not have an account yet.". But this message can not loaded now.

is there any solution?

marklandry
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Fri Feb 06, 2009 9:33 pm
Location: Denver
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by marklandry » Fri Sep 11, 2009 2:43 pm

Are you able to redirect the message to a part of the site that is not the front page? I don't think you can if you are using the standard joomla login module. You might want to go on the JED and search for one that will allow you to redirect an errant login to a different area. Wish I had more to offer... LKJ's on this post as well and far more hip than I with this stuff.

Good luck!

Mark

propheus
I've been banned!
Posts: 3
Joined: Tue Jan 10, 2006 12:20 pm

Re: how to hide the Main Body in 1.5 ??

Post by propheus » Sat Sep 12, 2009 9:08 am

hope she can help

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: how to hide the Main Body in 1.5 ??

Post by ljk » Sun Sep 13, 2009 2:10 am

Hello,

If you don't have the login module on the frontpage, I don't know why it wouldn't be showing the error message on the page you are on.

As Mark suggested, make sure that mod_login has the redirection login and logout set to a page other than the frontpage. If you mouse over the login and logout, you will see that it tries to go to the frontpage if you don't have them set.

Hope that helps, otherwise I don't know how to solve this problem.

Cheers.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca


Locked

Return to “Templates for Joomla! 1.5”