Forums / Templates, Stylesheets, Page Layout / Sidebox display for specific pages

Sidebox display for specific pages

Locked

Views: 1,922

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
9 Nov 2006, 6:20 PM
#1
lilymoon avatar

lilymoon

New Zenner

Join Date:
Nov 2006
Posts:
6
Plugin Contributions:
0

Sidebox display for specific pages

Hiya, I've searched the forum and tutorials but either no one has asked this question, I could not locate them via my search terms and/or its not possible... but here's my question:

Is there a way to have the sideboxes appear for specific pages only? I'm trying to move a static, informational site over to zencart in order to merge their products with their website as I figured it be easier to have it all together rather than various locations. It seems the EZ pages are set up for that, but I only want the sideboxes for the categories and store related functions, like reviews, best sellers, manufacturers, etc., to be displayed only on the store-related pages.

Is this possible? If so, how? Or is it easier to keep the static html page separate from the store stuff?

Thanks for your feedback!:yes:

11 Nov 2006, 9:21 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Sidebox display for specific pages

Read the readme in the css folder for css per page

Zen-Venom Get Bitten

11 Nov 2006, 6:21 PM
#3
lilymoon avatar

lilymoon

New Zenner

Join Date:
Nov 2006
Posts:
6
Plugin Contributions:
0

Re: Sidebox display for specific pages

Hi Kobra,

Thanks for your reply.

I read that page but how do I list the page name?

Here's one of the URL's that I need no side box:
/index.php?main_page=page&id=1&chapter=2

How can I do this for all pages under chapter?

Here's what I found on the CSS page (note, no file found in the commons folder as listed):

      page_name.css   // changes to one page
7 Jul 2007, 11:43 AM
#4
mantid avatar

mantid

New Zenner

Join Date:
May 2007
Posts:
3
Plugin Contributions:
0

Re: Sidebox display for specific pages

I am hoping you figured this out by now, but I have been searching for a couple days for this answer and ended up figuring it out myself based off what I found at https://www.zen-cart.com/tutorials/index.php?article=249 and a little web research. Hopefully it will provide help for someone else.

I wanted to show a sidebox ONLY for a specific chapter. I will use the search sidebox for these examples. Make sure the search box (or any boxes you want to apply this to) is turned on in Admin > Tools > Layout Boxes Controller.

Go to includes/modules/sideboxes and copy search.php (or any sideboxes you want to show/not show on specific chapters) to your template folder (includes/modules/sideboxes/YOUR_TEMPLATE).

Open the search.php file in your template folder and find:

  require($template->get_template_dir('tpl_search.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_search.php');

  $title = '<label>' . BOX_HEADING_SEARCH . '</label>';
  $title_link = false;
  require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
```To show the sidebox everywhere EXCEPT specific chapters, wrap this in a conditional statement so it looks like:

if (!in_array($chapter_id,explode(",",'1'))) {
require($template->get_template_dir('tpl_search.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_search.php');

$title = '<label>' . BOX_HEADING_SEARCH . '</label>';
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}


To make the sidebox show ONLY for specific chapters, just remove the "!" in front of !in_array, so it looks like:

if (in_array($chapter_id,explode(",",'1'))) {
require($template->get_template_dir('tpl_search.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_search.php');

$title = '<label>' . BOX_HEADING_SEARCH . '</label>';
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}


If you have a sidebox that is only going to show for ONE chapter only, another way to do it would be to wrap the code so it looks like:

if ($chapter_id == 1) {
require($template->get_template_dir('tpl_search.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_search.php');

$title = '<label>' . BOX_HEADING_SEARCH . '</label>';
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}

26 Oct 2008, 10:03 AM
#5
travellers avatar

travellers

Zen Follower

Join Date:
Oct 2008
Posts:
143
Plugin Contributions:
0

Re: Sidebox display for specific pages

I'm pretty sure this way would work for me in the most part, but its still not quite what I'm looking for.
I'm guessing I could replace the 'chapter' in your example with 'category' (using cPath= ?) so that a given sidebox would only appear on pages within a specific category, right? Well thats **really **close to what I'm after, but there would still be exceptions to that rule and the odd product in the odd category should/shouldn't show the box. What would be really neat is, having 'enabled' the sidebox in a particular category, you could then confirm or de-authorise its display when creating/modifying products **within **that category in the Admin. But I suppose thats a whole new level of modification, right?

The instructions say Insert Disk 3, but only two will fit...
https://www.shedtraders.co.uk
https://www.tobermorychocolate.co.uk

26 Oct 2008, 10:47 AM
#6
travellers avatar

travellers

Zen Follower

Join Date:
Oct 2008
Posts:
143
Plugin Contributions:
0

Re: Sidebox display for specific pages

Hmmmm.... so much for "I'm guessing I could..." above :(
I cant seem to modify this approach to work for categories rather than chapters after all. I tried

 if (in_array($category_id,explode(",",'65'))) {

but the sidebar then disappeared in **all **places. Noticing a product_id in the URL, I thought I'd try that instead just to see if it worked, but ```
if (in_array($products_id,explode(",",'182'))) {

So I'm doing something wrong, and the first thing that springs to mind as a possibility is twin if statements - are they okay? Because I'm attempting to use this on a new blank_sidebox page which carries its own if command for display at all - here's the complete content of that php file now, in case anyone can see an obvious hole!
<?php /** * blank sidebox - allows a blank sidebox to be added to your site * * @package templateSystem * @copyright 2007 Kuroi Web Design * @copyright Portions Copyright 2003-2007 Zen Cart Development Team * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $ */ // test if box should display $show_blank_sidebox = true; if (in_array($products_id,explode(",",'182'))) { if ($show_blank_sidebox == true) { require($template->get_template_dir('tpl_blank_sidebox.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_blank_sidebox.php'); $title = BOX_HEADING_BLANK_SIDEBOX; $title_link = false; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); } } ?>

The instructions say Insert Disk 3, but only two will fit...
https://www.shedtraders.co.uk
https://www.tobermorychocolate.co.uk