Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Disable sidebox banner on home page

Disable sidebox banner on home page

Locked

Views: 2,413

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
8 Jul 2010, 5:59 PM
#1
obelis avatar

obelis

New Zenner

Join Date:
May 2010
Posts:
16
Plugin Contributions:
0

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.

8 Jul 2010, 8:25 PM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

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.

9 Jul 2010, 3:06 AM
#3
obelis avatar

obelis

New Zenner

Join Date:
May 2010
Posts:
16
Plugin Contributions:
0

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...?

9 Jul 2010, 9:14 AM
#4
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

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

<?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);

}

?>
9 Jul 2010, 12:07 PM
#5
obelis avatar

obelis

New Zenner

Join Date:
May 2010
Posts:
16
Plugin Contributions:
0

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)

:happy:

11 Jul 2010, 1:16 PM
#6
obelis avatar

obelis

New Zenner

Join Date:
May 2010
Posts:
16
Plugin Contributions:
0

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;}

:wink: