Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2008
    Posts
    109
    Plugin Contributions
    0

    Default Removing Elements on Main Page Only

    Hi

    I've seen the answer to this before but have tried searching and cannot find it.

    I was chasing the code to comment out sections of the stylesheet for the main page only.

    It was similar to;

    If=main_page then ignore

    Any help would be really appreciated

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Removing Elements on Main Page Only

    To disable code on the home page:
    PHP Code:
    if (!$this_is_home_page) {
      
    //your code

    To run code on the home page only:
    PHP Code:
    if ($this_is_home_page) {
      
    //your code

    Note that this will not work inside the stylesheet.
    You can address elements occurring on the home page with #indexHome prefixed to the selector.

    #indexHome .leftBoxContents {
    Last edited by gjh42; 10 Dec 2008 at 12:31 PM.

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Removing Elements on Main Page Only

    Ran out of time to edit...

    You can address elements occurring on the home page with #indexHomeBody prefixed to the selector.

    #indexHomeBody .leftBoxContents {

  4. #4
    Join Date
    Oct 2008
    Posts
    109
    Plugin Contributions
    0

    Default Re: Removing Elements on Main Page Only

    Sorry i'm a bit new to CSS.

    If i cant use it in the style sheet where do i put it?

    and would "ignore" work as below
    if (!$this_is_home_page) {
    //ignore
    }

    and (sorry i know i'm pushing it with this many questions) will using #indexHomeBody in front of elements stop them occuring on the main page?

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Removing Elements on Main Page Only

    The #indexHomeBody prefix will address a common element *only* when it occurs on the home page. You can use this to add special styling instructions for the home page, like
    display: none;
    if you want the element to disappear there.



    if (!$this_is_home_page) {
    //ignore
    }

    //ignore
    is just a comment and will do nothing.
    Wrapping the if code as shown around your other code is what will cause that to be run only if not on the home page (i.e., ignored on the home page).

    This would be used in PHP files. You should learn something about how PHP works before trying to make edits like this.
    Look at www.w3schools.com for basic PHP and CSS tutorials.

  6. #6
    Join Date
    Oct 2008
    Posts
    109
    Plugin Contributions
    0

    Default Re: Removing Elements on Main Page Only

    Will do. Thanks alot for your time though. Did you know if there was an easy way to stop the footer appearing on the home page for the time being?

    Thanks again.

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Removing Elements on Main Page Only

    Look at /includes/templates/your_template/common/tpl_main_page.php (copy it from /template_default/ if needed.)

    There are notes in that file that describe how to disable elements, like the footer for the home page.

  8. #8
    Join Date
    Oct 2008
    Posts
    109
    Plugin Contributions
    0

    Default Re: Removing Elements on Main Page Only

    Ahh...exactly what I was after. Thanks - worked a treat!

 

 

Similar Threads

  1. v150 Removing side columns from main page ONLY
    By meljen in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 7 Sep 2012, 11:03 PM
  2. Removing Category Link on Main Page ONLY
    By cchan in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 24 May 2011, 06:44 PM
  3. Removing catagory titles on main page only??
    By skyegospel in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 20 Dec 2008, 11:43 AM
  4. moving sidebox elements to main page template
    By ckalech in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 28 Sep 2007, 10:49 PM
  5. Header overlapping main page elements...?
    By LloydDobbler in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 2 Apr 2007, 04:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg