Results 1 to 6 of 6
  1. #1
    Join Date
    May 2010
    Posts
    16
    Plugin Contributions
    0

    Default Disable sidebox banner on home page

    Hi Guys,

    I've got a snippet of code which I've tried to adapt to be used to switch off the sidebox banners on particular pages. I have tried to use it to disable the banners on my home page only but for some reason it doesn't seem to work correctly..
    .this is the code I used in the sidebox module override file-

    // test if box should display
    $show_banner_box = true;
    if (SHOW_BANNERS_GROUP_SET7 == '') {
    $show_banner_box = false;
    }

    // do not show if on index page
    if ($current_page_base == 'main_page') {
    $show_banner_box = false;
    //echo 'I am hiding!!' //. $current_page_base;
    }


    if ($show_banner_box == true) {
    $banner_box[] = TEXT_BANNER_BOX;
    $banner_box_group= SHOW_BANNERS_GROUP_SET7;

    This format has been used successfully before so I think the problem may be with the homepage/index page id...any help would be appreciated.

  2. #2
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Disable sidebox banner on home page

    instead of:
    if ($current_page_base == 'main_page')
    try using:
    if($this_is_home_page)

    $current_page_base will never equal 'main_page' - it will normally be equal to $_GET['main_page']. And even if $current_page_base equals 'index', then it may not be the home page either - it could be a sub-category or product listing.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  3. #3
    Join Date
    May 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Disable sidebox banner on home page

    Thanks for getting back to me.
    I tried that code but still no luck, it just seems to be
    ignoring the home page instruction for some reason.
    Any ideas...?

  4. #4
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,024
    Plugin Contributions
    3

    Default Re: Disable sidebox banner on home page

    This code works for me to remove the Categories sidebox from the main page (it's the complete categories sidebox code):

    Code:
    <?php
    
    /**
    
     * categories sidebox - prepares content for the main categories sidebox
    
     *
    
     * @package templateSystem
    
     * @copyright Copyright 2003-2005 Zen Cart Development Team
    
     * @copyright Portions Copyright 2003 osCommerce
    
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
    
     * @version $Id: categories.php 2718 2005-12-28 06:42:39Z drbyte $
    
     */
    
      if ($this_is_home_page) {
    
        $show_categories = false;
    
      } else {
    
        $show_categories = true;
    
      }
    
    
    
      if ($show_categories == true)
    
    {
    
        $main_category_tree = new category_tree;
    
        $row = 0;
    
        $box_categories_array = array();
    
    
    
    // don't build a tree when no categories
    
        $check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
    
        if ($check_categories->RecordCount() > 0) {
    
          $box_categories_array = $main_category_tree->zen_category_tree();
    
        }
    
    
    
        require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
    
    
    
        $title = BOX_HEADING_CATEGORIES;
    
        $title_link = false;
    
    
    
        require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    
    }
    
    ?>

  5. #5
    Join Date
    May 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Disable sidebox banner on home page

    Thanks for this, tried it in various permutations with no luck.
    Then I thought that perhaps the CSS might be overriding the code.
    So I managed to find a CSS fix as follows, for anyone in the same situation:

    'For a relatively small number of boxes, you can hide them with CSS on desired pages. This makes use of the page id applied to the body, and the id applied to each sidebox.

    If you want to hide the categories box on the login page, you can add to your stylesheet
    Code:
    #loginBody #categories {display: none;}

    You can use view source to find the page id and box id:

    <body id="loginBody"

    <div class="leftBoxContainer" id="categories" ' .

    In my case I used the main page id, (pageBody) and the
    box id (bannerbox) to give Code:
    #pageBody #bannerbox{display:none;}

    This worked perfectly, so now I can disable banners on the home page only. It should also be adaptable to any other page as required.


    ps:
    (The firefox web developer plugin is very useful for finding div ids if you're in a hurry; open your page in FF, right click on the relevant element and choose menu item 'inspect element' to view the div id display tree)


  6. #6
    Join Date
    May 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Disable sidebox banner on home page

    Update;
    I have found that you actually need to use both methods in order to disable sideboxes on particular pages as required.
    First open the relevant sidebox.php file and adapt this code to your requirements:

    if ($this_is_home_page) {
    $show_banner_box = false;
    } else {
    $show_banner_box = true;
    }

    save to includes/modules/sideboxes/Your_template/

    Then go to your stylesheet and adapt this code as necessary:

    #pageBody #bannerbox {display: none;}


 

 

Similar Threads

  1. Disable Footer Banner all pages except Home
    By kburner in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 27 Dec 2010, 08:39 PM
  2. how do I disable banner sidebox header?
    By kkymn in forum Basic Configuration
    Replies: 16
    Last Post: 27 Sep 2009, 02:03 AM
  3. Disable Certain Sidebox on Home Page
    By CoolCarPartsOnline in forum General Questions
    Replies: 3
    Last Post: 8 Feb 2009, 10:19 PM
  4. Disable BAnner Specific Page(s) Only
    By traders in forum Basic Configuration
    Replies: 0
    Last Post: 10 Dec 2007, 02:48 PM
  5. Disable Login at home page?
    By amieco in forum Basic Configuration
    Replies: 4
    Last Post: 15 Jun 2007, 08:00 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR