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  [ 40 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Sep 05, 2008 3:31 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Apr 12, 2007 1:18 pm
Posts: 13
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


Top
 Profile  
 
PostPosted: Fri Sep 05, 2008 7:20 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed Apr 11, 2007 2:06 pm
Posts: 213
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.


Top
 Profile  
 
PostPosted: Sat Sep 13, 2008 8:42 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Oct 31, 2007 7:19 pm
Posts: 32
Location: Singapore
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 :)

_________________
http://www.onsponge.com A parenting and educational site for primary school kids
Signature rules - Literal URL's Only and no more then 4 lines.


Top
 Profile  
 
PostPosted: Mon Sep 15, 2008 3:02 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
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:
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:
<?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


Top
 Profile  
 
PostPosted: Mon Sep 29, 2008 6:35 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sun Aug 28, 2005 11:23 am
Posts: 958
Location: New York
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:
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!!!


Top
 Profile  
 
PostPosted: Mon Sep 29, 2008 9:00 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Tue Jan 22, 2008 8:01 pm
Posts: 61
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 ;)

_________________
Davide Taddei
http://davidetaddei.[URL banned].com


Top
 Profile  
 
PostPosted: Sun Oct 12, 2008 12:22 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Oct 05, 2008 2:53 am
Posts: 5
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.


Top
 Profile  
 
PostPosted: Mon Oct 13, 2008 9:10 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Tue Jan 22, 2008 8:01 pm
Posts: 61
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.

_________________
Davide Taddei
http://davidetaddei.[URL banned].com


Top
 Profile  
 
PostPosted: Mon Oct 13, 2008 3:47 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Oct 05, 2008 2:53 am
Posts: 5
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


Top
 Profile  
 
PostPosted: Mon Oct 13, 2008 4:54 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Oct 05, 2008 2:53 am
Posts: 5
Don't worry .

I got it !

Thanks you


Top
 Profile  
 
PostPosted: Sun Nov 30, 2008 11:34 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Nov 30, 2008 11:26 am
Posts: 1
Menus > Mainmenu* > Home > Base Options = all sets by 0

and ABRAKADABRA!
Attachment:
aa.JPG


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Sat Jan 24, 2009 11:13 pm 
User avatar
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Jul 14, 2008 6:44 am
Posts: 1
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:
defined( '_JEXEC' ) or die( 'Restricted access' );
$pageview = JRequest::getVar('view', '');

...


Thanks! Works perfectly. :D


Top
 Profile  
 
PostPosted: Tue Aug 04, 2009 6:50 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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:
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:
<?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:
  <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!!!!!


Top
 Profile  
 
PostPosted: Wed Aug 05, 2009 3:45 am 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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...


Top
 Profile  
 
PostPosted: Wed Aug 05, 2009 6:19 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
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


Top
 Profile  
 
PostPosted: Sun Aug 09, 2009 6:34 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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:
<?php if ($pageview != 'frontpage') : ?>
call up the new css things
<?php endif; ?>


Any help you could give would be very seriously appreciated. :D


Top
 Profile  
 
PostPosted: Sun Aug 09, 2009 8:04 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
Hello,

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

Code:
<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


Top
 Profile  
 
PostPosted: Mon Aug 10, 2009 7:57 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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:
<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???


Top
 Profile  
 
PostPosted: Tue Aug 11, 2009 3:07 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
maybe something like this??
Code:
<style type="text/css" media="screen">
/*<![CDATA[*/
   if ($pageview == 'com_content&view=category&id=35') {
      echo ("
         #background {
            background: url...
         }
                       
      ");
   }
?>
/*]]>*/
</style>


Top
 Profile  
 
PostPosted: Tue Aug 11, 2009 5:30 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
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:
   $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:
<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:
   $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


Top
 Profile  
 
PostPosted: Fri Aug 28, 2009 6:37 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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:
$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:
<?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?


Top
 Profile  
 
PostPosted: Sun Aug 30, 2009 1:27 am 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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


Top
 Profile  
 
PostPosted: Sun Aug 30, 2009 4:37 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
Hi,

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

Code:
<?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


Top
 Profile  
 
PostPosted: Tue Sep 01, 2009 9:27 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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:
<?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!!!


Top
 Profile  
 
PostPosted: Tue Sep 01, 2009 9:40 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
Nevermind... looked a little harder

Code:
<?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!!!


Top
 Profile  
 
PostPosted: Wed Sep 02, 2009 2:27 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
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


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 12:05 pm 
I've been banned!

Joined: Tue Jan 10, 2006 12:20 pm
Posts: 3
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:
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:
<?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?


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 2:43 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Feb 06, 2009 9:33 pm
Posts: 73
Location: Denver
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


Top
 Profile  
 
PostPosted: Sat Sep 12, 2009 9:08 am 
I've been banned!

Joined: Tue Jan 10, 2006 12:20 pm
Posts: 3
hope she can help


Top
 Profile  
 
PostPosted: Sun Sep 13, 2009 2:10 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Jan 28, 2006 11:51 pm
Posts: 700
Location: Vancouver BC
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next



Who is online

Users browsing this forum: No registered users and 4 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