Zen Cart Logo
Forums / General Questions / Show/Hide sideboxes based on page

Show/Hide sideboxes based on page

Views: 43,781

Results 81 to 100 of 189
28 Jan 2010, 3:54 PM
#81
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Show/Hide sideboxes based on page

Mmm yeah... posting at 3am... too tired to articulate that the individual sideboxes need to be controlled in their respective files and not in tpl_main_page:)

28 Jan 2010, 3:57 PM
#82
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Ajeh:

Just curious ... are you trying to turn off individual sideboxes or are you trying to turn off columns? :unsure:

These variables and their values:
$flag_disable_left = true;
$flag_disable_right = true;

are used to control the left and right columns ... and, when placed correctly in the code the whole column will turn off ...

If you want to turn off individual sideboxes, look at how the featured.php sidebox module is written where you see:

// test if box should display
$show_featured= true;

if ($show_featured == true) {

> 
> currently, nothing "controls" or changes that sidebox but the code is there so that you "could" change when this shows such as only show the sidebox when on the main page:
> ```
// test if box should display
  $show_featured= true;

if (!$this_is_home_page) {
  $show_featured= false;
}
  if ($show_featured == true) {

Notice on this sidebox how the IF statement surrounds the whole code ...

Any sidebox where this type of IF does not exist, you can set it up yourself to have similar logic ...

Individual sideboxes...I will try it tonight. Thank you!

28 Jan 2010, 4:32 PM
#83
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

gjh42:

Mmm yeah... posting at 3am... too tired to articulate that the individual sideboxes need to be controlled in their respective files and not in tpl_main_page:)

Dontcha just hate helpin' in your sleep ... then waking up to find out what you really said versus what you thought you meant? :lamo:

28 Jan 2010, 9:25 PM
#84
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

I am not good at this... I tried your code with includes/modules/sideboxes/temp file/testimonials_manager. And it still did not work.

// test if box should display
 $show_featured= true;
if (!$this_is_home_page) {
  $show_featured= false;
}
  if ($show_featured == true) {


$page_query = $db->Execute("select testimonials_id, testimonials_image, testimonials_title, testimonials_html_text, date_added  from " . TABLE_TESTIMONIALS_MANAGER . " where status = 1  and language_id = " . (int)$_SESSION['languages_id'] . " order by rand(), testimonials_title limit " . MAX_DISPLAY_TESTIMONIALS_MANAGER_TITLES ."");
if ($page_query->RecordCount()>0) {
      $title =  BOX_HEADING_TESTIMONIALS_MANAGER;
      $box_id =  testimonials_manager;
      $rows = 0;
      while (!$page_query->EOF) {
        $rows++;
        $page_query_list[$rows]['id'] = $page_query->fields['testimonials_id'];
        $page_query_list[$rows]['name']  = $page_query->fields['testimonials_title'];
        $page_query_list[$rows]['story']  = $page_query->fields['testimonials_html_text'];
		$page_query_list[$rows]['image'] = $page_query->fields['testimonials_image'];

        $page_query->MoveNext();
      }
      $left_corner = false;
      $right_corner = false;
      $right_arrow = false;
      $title_link = false;
      require($template->get_template_dir('tpl_testimonials_manager.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_testimonials_manager.php');
      require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
//EOF	

I also tried it with changing the word featured to testimonials_manager....it takes sidebox and footer and everything off.

// test if box should display
 $show_testimonials_manager= true;
if (!$this_is_home_page) {
  $show_testimonials_manager= false;
}
  if ($show_testimonials_manager == true) {


$page_query = $db->Execute("select testimonials_id, testimonials_image, testimonials_title, testimonials_html_text, date_added  from " . TABLE_TESTIMONIALS_MANAGER . " where status = 1  and language_id = " . (int)$_SESSION['languages_id'] . " order by rand(), testimonials_title limit " . MAX_DISPLAY_TESTIMONIALS_MANAGER_TITLES ."");
if ($page_query->RecordCount()>0) {
      $title =  BOX_HEADING_TESTIMONIALS_MANAGER;
      $box_id =  testimonials_manager;
      $rows = 0;
      while (!$page_query->EOF) {
        $rows++;
        $page_query_list[$rows]['id'] = $page_query->fields['testimonials_id'];
        $page_query_list[$rows]['name']  = $page_query->fields['testimonials_title'];
        $page_query_list[$rows]['story']  = $page_query->fields['testimonials_html_text'];
		$page_query_list[$rows]['image'] = $page_query->fields['testimonials_image'];

        $page_query->MoveNext();
      }
      $left_corner = false;
      $right_corner = false;
      $right_arrow = false;
      $title_link = false;
      require($template->get_template_dir('tpl_testimonials_manager.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_testimonials_manager.php');
      require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
//EOF	
28 Jan 2010, 10:03 PM
#85
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

I changed my code for the featured sidebox module to:

// test if box should display
  $show_featured= true;

if (!$this_is_home_page) {
  $show_featured= false;
}

and only see the Featured Sidebox on the Home Page ...

Now, let's check a few things ...

1 What version of Zen Cart?

2 When you say Featured Sidebox ... you do mean the Featured Sidebox in the Left or Right Column, correct?

3 What happens if you switch to Classic Template

4 Are you using templates and overrides?

5 in the Tools ... Developers Tool Kit ... if you do a search for:
if ($show_featured == true) {

what files come up, as in where are they located?

28 Jan 2010, 10:05 PM
#86
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

Also check the IF statements ... do they ALL have closing brackets?

I am seeing an odd number in what you displayed ... :unsure:

28 Jan 2010, 11:23 PM
#87
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Ajeh:

I changed my code for the featured sidebox module to:

// test if box should display
$show_featured= true;

if (!$this_is_home_page) {
$show_featured= false;
}

> 
> and only see the Featured Sidebox on the Home Page ...
> 
> Now, let's check a few things ...
> 
> 1 What version of Zen Cart? 1.3.8a
> 
> 2 When you say Featured Sidebox ... you do mean the Featured Sidebox in the Left or Right Column, correct? the sideboxes on both left or right columns they are newsletter called subscribe, testimonials_manager, links sidebox
> 
> 3 What happens if you switch to Classic Template
> 
> 4 Are you using templates and overrides? Yes
> 
> 5 in the Tools ... Developers Tool Kit ... if you do a search for:
>   if ($show_featured == true) {
> 
> It is located at: includes/modules/sideboxes/featured.php
> 
> what files come up, as in where are they located?

I went to includes/modules/sideboxes/temp name/testimonials_manager.php

inserted this code at top
```html
$show_featured= true;

if (!$this_is_home_page) {
  $show_featured= false;
}
I even tried it with changing featured to testimonials_manager and did not work.

Should I put code into includes/templates/temp file/sideboxes/tpl_testimonials_manager.php instead?

28 Jan 2010, 11:28 PM
#88
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

No ... you need to post your code for the testimonial manager from the first line to the last line so we can see that you have balanced all of the IF statements ... :smile:

28 Jan 2010, 11:32 PM
#89
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

includes/modules/sideboxes/temp/testimonials_manager.php

// test if box should display
$show_featured= true;

if (!$this_is_home_page) {
  $show_featured= false;
}

$page_query = $db->Execute("select testimonials_id, testimonials_image, testimonials_title, testimonials_html_text, date_added  from " . TABLE_TESTIMONIALS_MANAGER . " where status = 1  and language_id = " . (int)$_SESSION['languages_id'] . " order by rand(), testimonials_title limit " . MAX_DISPLAY_TESTIMONIALS_MANAGER_TITLES ."");
if ($page_query->RecordCount()>0) {
      $title =  BOX_HEADING_TESTIMONIALS_MANAGER;
      $box_id =  testimonials_manager;
      $rows = 0;
      while (!$page_query->EOF) {
        $rows++;
        $page_query_list[$rows]['id'] = $page_query->fields['testimonials_id'];
        $page_query_list[$rows]['name']  = $page_query->fields['testimonials_title'];
        $page_query_list[$rows]['story']  = $page_query->fields['testimonials_html_text'];
		$page_query_list[$rows]['image'] = $page_query->fields['testimonials_image'];

        $page_query->MoveNext();
      }
      $left_corner = false;
      $right_corner = false;
      $right_arrow = false;
      $title_link = false;
      require($template->get_template_dir('tpl_testimonials_manager.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_testimonials_manager.php');
      require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
//EOF	
28 Jan 2010, 11:43 PM
#90
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

Try this code, instead:

// test if box should display
$show_testimonials_manager= true;

if (!$this_is_home_page) {
  $show_testimonials_manager= false;
}

if ($show_testimonials_manager == true) {
  $page_query = $db->Execute("select testimonials_id, testimonials_image, testimonials_title, testimonials_html_text, date_added  from " . TABLE_TESTIMONIALS_MANAGER . " where status = 1  and language_id = " . (int)$_SESSION['languages_id'] . " order by rand(), testimonials_title limit " . MAX_DISPLAY_TESTIMONIALS_MANAGER_TITLES ."");
  if ($page_query->RecordCount()>0) {
      $title =  BOX_HEADING_TESTIMONIALS_MANAGER;
      $box_id =  testimonials_manager;
      $rows = 0;
      while (!$page_query->EOF) {
        $rows++;
        $page_query_list[$rows]['id'] = $page_query->fields['testimonials_id'];
        $page_query_list[$rows]['name']  = $page_query->fields['testimonials_title'];
        $page_query_list[$rows]['story']  = $page_query->fields['testimonials_html_text'];
		$page_query_list[$rows]['image'] = $page_query->fields['testimonials_image'];

        $page_query->MoveNext();
      }
      $left_corner = false;
      $right_corner = false;
      $right_arrow = false;
      $title_link = false;
      require($template->get_template_dir('tpl_testimonials_manager.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_testimonials_manager.php');
      require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
}
//EOF

The variable:
$show_testimonials_manager

could be called anything ... but I like them to match the name of the sidebox ... plus, you do not want to repeat the same variables in sideboxes to avoid issues ...

But ... the variable must match the IF statement test ...

28 Jan 2010, 11:52 PM
#91
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

It hide the side box on product page, but also hides footer, banners, everything else from where side box was down.

28 Jan 2010, 11:59 PM
#92
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Ajeh:

Try this code, instead:

// test if box should display
$show_testimonials_manager= true;

if (!$this_is_home_page) {
$show_testimonials_manager= false;
}

if ($show_testimonials_manager == true) {
$page_query = $db->Execute("select testimonials_id, testimonials_image, testimonials_title, testimonials_html_text, date_added from " . TABLE_TESTIMONIALS_MANAGER . " where status = 1 and language_id = " . (int)$_SESSION['languages_id'] . " order by rand(), testimonials_title limit " . MAX_DISPLAY_TESTIMONIALS_MANAGER_TITLES ."");
if ($page_query->RecordCount()>0) {
$title = BOX_HEADING_TESTIMONIALS_MANAGER;
$box_id = testimonials_manager;
$rows = 0;
while (!$page_query->EOF) {
$rows++;
$page_query_list[$rows]['id'] = $page_query->fields['testimonials_id'];
$page_query_list[$rows]['name'] = $page_query->fields['testimonials_title'];
$page_query_list[$rows]['story'] = $page_query->fields['testimonials_html_text'];
$page_query_list[$rows]['image'] = $page_query->fields['testimonials_image'];

    $page_query->MoveNext();
  }
  $left_corner = false;
  $right_corner = false;
  $right_arrow = false;
  $title_link = false;
  require($template->get_template_dir('tpl_testimonials_manager.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_testimonials_manager.php');
  require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}

}
//EOF

> 
> The variable:
> $show_testimonials_manager
> 
> could be called anything ... but I like them to match the name of the sidebox ... plus, you do not want to repeat the same variables in sideboxes to avoid issues ...
> 
> But ... the variable must match the IF statement test ...

I tried it again and it worked this time!:frusty::frusty:
29 Jan 2010, 12:05 AM
#93
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

<insert dancing here> ... :cool:

7 Feb 2010, 9:58 AM
#94
adi2009 avatar

adi2009

New Zenner

Join Date:
Dec 2009
Location:
Sarajevo
Posts:
80
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Great topic, exactly what I am looking for:bigups:

I hope you can help me with this:

  1. I would like to hide categories and chcategories (Categories Dressing) sideboxes on these two pages/links

/index.php?main_page=contact_us
/index.php?main_page=news_archiv

  1. Also, I need to hide standard categories sidebox in these categories (cPaths)

index.php?main_page=index&cPath=148
index.php?main_page=index&cPath=146

I am not sure is this possible to do with css trick as Kuroi mentioned on first page, or editing 'common/tpl_main_page.php' and how?

Thnx in advance, all suggestions are welcome:wink:

7 Feb 2010, 3:58 PM
#95
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

It would be similar where you can setup an IF around the code, if it doesn't exist already and the $show_my_sidebox would be whatever variable you are using in that sidebox ...

if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv') {
  $show_my_sidebox = false;
} 

For the cPath you can use:
$_GET['cPath']

For the current categories_id you can use:
$current_category_id

7 Feb 2010, 7:16 PM
#96
adi2009 avatar

adi2009

New Zenner

Join Date:
Dec 2009
Location:
Sarajevo
Posts:
80
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Ajeh:

It would be similar where you can setup an IF around the code, if it doesn't exist already and the $show_my_sidebox would be whatever variable you are using in that sidebox ...

if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv') {
$show_my_sidebox = false;
}

> 
> For the cPath you can use:
> $_GET['cPath']
> 
> For the current categories_id you can use:
> $current_category_id

huh:blush: as I am still new zenner I dont now where to start: where should I insert this code? I assume it need sto be inserted in '/templates/mytemplate/common/tpl_main_page.php'? I tryed to set this code in tpl_main_page.php

if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv') {
$show_my_sidebox = false;
}


exactly bellow this part of ocde:

the following IF statement can be duplicated/modified as needed to set additional flags
if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
$flag_disable_right = true;
}


looking like this

the following IF statement can be duplicated/modified as needed to set additional flags
if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
$flag_disable_right = true;
}

if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv') {
$show_my_sidebox = false;
}


but nothing happens. Also I tryed replacing  "$show_my_sidebox = false;" with  "$show_categories = false;" but still nothing changes..
7 Feb 2010, 7:47 PM
#97
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

This code is designed for the individual sideboxes ...

If you look at how the specials sidebox is done in the:
/includes/modules/sideboxes/specials.php

// test if box should display
  $show_specials= false;

  if (isset($_GET['products_id'])) {
    $show_specials= false;
  } else {
    $show_specials= true;
  }

  if ($show_specials == true) {
// all the code that makes the box here    }
  }

This sidebox uses:
$show_specials

because it matches the sidebox name ... it could use $fred but that wouldn't make sense for easy coding ... :smile:

The idea is, there are conditions set as to when the variable:
$show_specials is true or false

The IF around all of the code for:
if ($show_specials == true) {

makes this sidebox show or not show when the various conditions are true ...

For any sidebox, the same logic can be built ...

1 you need the logical tests for when to show or not show a sidebox

2 the code that makes the sidebox display must be surrounded by an IF statement such as:

  if ($show_specials == true) {
// all the code that makes the box here
  }
7 Feb 2010, 8:24 PM
#98
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show/Hide sideboxes based on page

In this case, both #categories and #chcategories use the same template file (tpl_categories.php) - that's the way fragfutter set it up for chcategories, and it conveniently worked with Categories Dressing.

You can control the sideboxes separately by using the test in the module files. In /includes/modules/sideboxes/your_template/ch_categories.php, find this:php //CHRISTOPH BOF require_once (DIR_WS_CLASSES . 'ch_categories_tree_generator.php'); and add above itphp $show_chcategories = true; if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv') { $show_chcategories = false; } if ($show_chcategories){ and at the bottom of the file just before the ?>, add } to get```php
}?>

Do the same kind of thing in /includes/modules/sideboxes/your_template/categories.php, to get```php
$show_categories = true;
if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv' or (int)$_GET['cPath']=='146' or (int)$_GET['cPath']=='148') {
  $show_categories = false;
}
if ($show_categories){

    $main_category_tree = new category_tree;
    $row = 0;
```and```php
}?>
9 Feb 2010, 7:07 AM
#99
adi2009 avatar

adi2009

New Zenner

Join Date:
Dec 2009
Location:
Sarajevo
Posts:
80
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

@Ajeh

thnx for detail explanation, it helped me better understand how sideboxes based on page working :bigups:

gjh42:

In this case, both #categories and #chcategories use the same template file (tpl_categories.php) - that's the way fragfutter set it up for chcategories, and it conveniently worked with Categories Dressing.

You can control the sideboxes separately by using the test in the module files. In /includes/modules/sideboxes/your_template/ch_categories.php, find this:php //CHRISTOPH BOF require_once (DIR_WS_CLASSES . 'ch_categories_tree_generator.php'); and add above itphp $show_chcategories = true; if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv') { $show_chcategories = false; } if ($show_chcategories){ and at the bottom of the file just before the ?>, add } to get```php
}?>

> Do the same kind of thing in /includes/modules/sideboxes/your_template/categories.php, to get```php
$show_categories = true;
if ($_GET['main_page']=='contact_us' or $_GET['main_page']=='news_archiv' or (int)$_GET['cPath']=='146' or (int)$_GET['cPath']=='148') {
  $show_categories = false;
}
if ($show_categories){

    $main_category_tree = new category_tree;
    $row = 0;
```and```php
}?>

as always Glenn, your code works like charm:smile: Thanks man

also now I understand this code better how it exactly works so I tryed this code on other two additional sideboxes I have on my site (custom Blank sidebox from author Kuroi) and its all working great:wink:

19 Feb 2010, 11:48 PM
#100
steveneee avatar

steveneee

New Zenner

Join Date:
Feb 2010
Posts:
1
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Hi all,
Noob here.

Exhaustively read entire thread and did not see an answer to the following question...

How do I keep the manufacturer_info side box from disappearing when listing a manufacturer's products?
ie. /index.php?main_page=index&manufacturers_id=8

Doesn't make sense to show manufacturer_info box when all a manufacturer's products are displayed?

Take a look at the site:
sidebox missing from specific manufacturer product list
http://www.regionalmarketplace.us/cartshp/index.php?main_page=index&manufacturers_id=8

individual products show sidebox:
http://www.regionalmarketplace.us/cartshp/index.php?main_page=product_info&cPath=65&products_id=181

Any help is greatly appreciated.