Forums / Templates, Stylesheets, Page Layout / Looking for some help with turning on a sidebox for secific pages

Looking for some help with turning on a sidebox for secific pages

Views: 1,389

Results 1 to 11 of 11
15 May 2013, 6:58 PM
#1
boydbreen avatar

boydbreen

New Zenner

Join Date:
Oct 2012
Posts:
48
Plugin Contributions:
0

Looking for some help with turning on a sidebox for secific pages

Hi Everyone

I have recently made a small contact form in a custom sidebox which I am happpy with everything works ok

I require some help modyfing the box as I only want to display this sidebox on a dozen or so pages not on all the pages.

I have tried some if statements but dont seem to have a grasp on this one

many Thanks in advance

Boyd

15 May 2013, 8:02 PM
#3
boydbreen avatar

boydbreen

New Zenner

Join Date:
Oct 2012
Posts:
48
Plugin Contributions:
0

Re: Looking for some help with turning on a sidebox for secific pages

Hi Stevesh

Thanks for this I have had a look and am unsure about this

If your sidebox module doesn't have a conditional such as if ($show_featured == true) { ... } wrapped around the code, then just add it (changing the variable name to something suitable and unique for your sidebox to avoid unintentionally turning off other sideboxes.

This is my sidebox php just noy sure how to add the conditional wrapped around the code I have tried looking at other mods but am still unsure

<?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 $ */ $content = ''; $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">'; // Replace the text and HTML tags between the apostophes on lines 19 and 20. // Use as many or as few lines using this model as you need for your custom content. // If you have a multilingual site define your text in the languages/YOUR_LANGUAGE/extra_definitions/blank_sidebox_defines.php and include it as shown in line 19. // If your site is monolingual, you can put the text right here as shown on line 20 (and nobody will know!) $content .= '<p>' . TEXT_BLANK_SIDEBOX . '</p>'; $content .= '<form id="Oform3" name="form3" action="contact_send.php" method="post" enctype="application/x-www-form-urlencoded"> <p style="font-size: 11pt; color: black ">Name:</p> <input type="text" class="Gform1" name="name" /> <p style="font-size: 11pt; color: black ">Telephone No:</p> <input type="text" class="Gform2" name="telephone" /> <p style="font-size: 11pt; color: black ">Email:</p> <input type="text" class="Gform3" name="email" /> <p style="font-size: 11pt; color: black ">Postcode:</p> <input type="text" class="Gform4" name="postcode" /> <p style="font-size: 11pt; color: black ">Message</p> <textarea name="message" class="Gform5" rows="5" cols="1"> Text Area</textarea> <input type="submit" class="Gform6" name="form8" value="Submit" /> </form>'; $content .= '</div>'; ?>
15 May 2013, 8:35 PM
#4
gjh42 avatar

gjh42

Black Belt

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

Re: Looking for some help with turning on a sidebox for secific pages

Is your sidebox module file still named blank_sidebox.php? If so, just add the test above```php
$content = '';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

//your code

$content .= '</div>';

}


You want to adapt this test from tpl_main_page.php for your multi-page display test:```php
// 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;
  }
``````php
  if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
    $show_blank_sidebox = false;
  } else {
    $show_blank_sidebox = true;
  }

if ($show_blank_sidebox) {
$content = '';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

//your code

$content .= '</div>';

}
15 May 2013, 8:39 PM
#5
gjh42 avatar

gjh42

Black Belt

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

Re: Looking for some help with turning on a sidebox for secific pages

Switch around the show statements according to which way is easier to define. If you only want to show the sidebox on certain pages, you would use```php
$show_blank_sidebox = true;
} else {
$show_blank_sidebox = false;
}

15 May 2013, 9:27 PM
#6
boydbreen avatar

boydbreen

New Zenner

Join Date:
Oct 2012
Posts:
48
Plugin Contributions:
0

Re: Looking for some help with turning on a sidebox for secific pages

Hi Glen

I have it working to a degree I have manged to diplsay the sidebox on one category only using the following

<?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 ($current_page_base == 'index' and $cPath == '1_2' ) { $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); } ?>

How can I extend this to include a product path too as I only want to display this on 6 pages

if ($current_page_base == 'index' and $cPath == '1_2' ) {
$show_blank_sidebox = true;

I have tried adding
and $pPath == 1
and $product_id == 1

but dont seem to be able to set it to a specific product ppage

Thanks again for all your help

15 May 2013, 9:39 PM
#7
gjh42 avatar

gjh42

Black Belt

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

Re: Looking for some help with turning on a sidebox for secific pages

Exactly what pages do you want to display this on? Product info pages use a different page base than category or product listing pages. For these you would use something like```php
if ($current_page_base == 'product_info' and ($products_id == '234' or $products_id == '169')) {

15 May 2013, 9:42 PM
#8
gjh42 avatar

gjh42

Black Belt

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

Re: Looking for some help with turning on a sidebox for secific pages

If you have a substantial list of product info pages, you could use```php
if ($current_page_base == 'product_info' and in_array($products_id, explode(',','234,169,789,54,77,345'))) {

15 May 2013, 9:58 PM
#9
boydbreen avatar

boydbreen

New Zenner

Join Date:
Oct 2012
Posts:
48
Plugin Contributions:
0

Re: Looking for some help with turning on a sidebox for secific pages

Hi Glenn

I have tried the following both ways but dont seem to be able to get it to work here is my code

<?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 = false; if ($current_page_base == 'product_info' and in_array($products_id, explode(',','1,2,3,4,5,6'))) { $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); } ?>
15 May 2013, 11:31 PM
#10
boydbreen avatar

boydbreen

New Zenner

Join Date:
Oct 2012
Posts:
48
Plugin Contributions:
0

Re: Looking for some help with turning on a sidebox for secific pages

Hi Everyone

I managed to get it to work ok with this

if ($current_page_base == 'product_info' and $_GET['products_id'] == '4' or $_GET['products_id'] == '1' or $_GET['products_id'] == '2' or $_GET['products_id'] == '3') {
$show_blank_sidebox = false;

16 May 2013, 1:39 AM
#11
gjh42 avatar

gjh42

Black Belt

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

Re: Looking for some help with turning on a sidebox for secific pages

It may be possible that the $products_id variable is not yet set when the sidebox is processed. $_GET[] variables are present from the moment the page starts processing, so can be more reliable. You do have a flaw in your test code which is masked by the fact that only product info pages will have $_GET['products_id'] set: the set of ids is not grouped to require the current page base for any but the first one. For good practice, it should look like this: ```
if ($current_page_base == 'product_info' and ($_GET['products_id'] == '4' or $_GET['products_id'] == '1' or $_GET['products_id'] == '2' or $_GET['products_id'] == '3')) {