Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / how to set sideboxes only on mainpage?

how to set sideboxes only on mainpage?

Locked

Views: 2,550

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
14 Feb 2007, 6:36 PM
#1
jelleh avatar

jelleh

New Zenner

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

how to set sideboxes only on mainpage?

Hi

I'd like to use some boxes like "new products" etc, but they may only be visible on the mainpage of the shop, not on the categorie pages or on the shopping-cart page. I can't find were to edit this.

Thank You

Jelle

14 Feb 2007, 6:38 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: how to set sideboxes only on mainpage?

Sideboxes can be customized ...

To know if you are on the main home page there is a variable:
$this_is_home_page

That can be used in an IF statement on the sidebox to allow/stop it from displaying ...

Using your templates and override directories, you can customize the sideboxes to display when you want them to ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

21 May 2007, 11:22 PM
#3
peacefuldaze avatar

peacefuldaze

New Zenner

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

Re: how to set sideboxes only on mainpage?

hi ajeh,
i am still a new zenner and need the same help. if you could take a moment, could you explain this in detail or point me to a thread that may have the answer. what coding do i need and where does is need to be placed to ensure the sidebox will only appear on the main page. thanks in adavance:-D

22 May 2007, 1:22 AM
#4
ajeh avatar

ajeh

Oba-san

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

Re: how to set sideboxes only on mainpage?

Let's say you want the sidebox
/includes/modules/sideboxes/whats_new.php

to only appear on the main page ...

Copy to your templates and overrides directory:
/includes/modules/sideboxes/your_templates_dir/whats_new.php

The original code looks like this:

// display limits
//$display_limit = zen_get_products_new_timelimit();
      $display_limit = zen_get_new_date_range();
  $random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
                           from " . TABLE_PRODUCTS . " p
                           where p.products_status = 1 " . $display_limit . "
                           limit " . MAX_RANDOM_SELECT_NEW;

  $random_whats_new_sidebox_product = zen_random_select($random_whats_new_sidebox_product_query);

  if ($random_whats_new_sidebox_product->RecordCount() > 0 ) {
    $whats_new_price = zen_get_products_display_price($random_whats_new_sidebox_product->fields['products_id']);
    $random_whats_new_sidebox_product->fields['products_name'] = zen_get_products_name($random_whats_new_sidebox_product->fields['products_id']);
    $random_whats_new_sidebox_product->fields['specials_new_products_price'] = zen_get_products_special_price($random_whats_new_sidebox_product->fields['products_id']);
    require($template->get_template_dir('tpl_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_whats_new.php');
    $title =  BOX_HEADING_WHATS_NEW;
    $title_link = FILENAME_PRODUCTS_NEW;
    require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
  }

Let's change it a bit ...

We want to add a condition for an IF statement to test should this show ...

Change the code to read:

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

// only show if the main page
  if ($this_is_home_page == true) {
    $show_whats_new= true;
  } else {
    $show_whats_new= false;
  }
    

if ($show_whats_new == true) {
// display limits
//$display_limit = zen_get_products_new_timelimit();
      $display_limit = zen_get_new_date_range();
  $random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
                           from " . TABLE_PRODUCTS . " p
                           where p.products_status = 1 " . $display_limit . "
                           limit " . MAX_RANDOM_SELECT_NEW;

  $random_whats_new_sidebox_product = zen_random_select($random_whats_new_sidebox_product_query);

  if ($random_whats_new_sidebox_product->RecordCount() > 0 ) {
    $whats_new_price = zen_get_products_display_price($random_whats_new_sidebox_product->fields['products_id']);
    $random_whats_new_sidebox_product->fields['products_name'] = zen_get_products_name($random_whats_new_sidebox_product->fields['products_id']);
    $random_whats_new_sidebox_product->fields['specials_new_products_price'] = zen_get_products_special_price($random_whats_new_sidebox_product->fields['products_id']);
    require($template->get_template_dir('tpl_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_whats_new.php');
    $title =  BOX_HEADING_WHATS_NEW;
    $title_link = FILENAME_PRODUCTS_NEW;
    require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
  }
} // eof: test $show_whats_new

Now it will only show when the variable $this_is_home_page evaluates to true ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

25 May 2007, 7:14 AM
#5
dwijadas avatar

dwijadas

New Zenner

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

Re: how to set sideboxes only on mainpage?

Hi,

Your reply was great help to me. Are there variable for other pages too ? Lets say I want to hide "shopping cart" side box on checkout page.

How do I do that ? If the variable not existing then how can we define the variable ?

this will be great help in customizing side bad based on current page.

Thanks,
Sena

25 May 2007, 8:07 AM
#6
dwijadas avatar

dwijadas

New Zenner

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

Re: how to set sideboxes only on mainpage?

I did it.

$current_page = is always having current page name .. by checking the page name I manage to hide side boxes as and when needed.

thanks,
Sena.

7 Jul 2007, 2:13 AM
#7
kmh avatar

kmh

New Zenner

Join Date:
May 2007
Location:
Sydney, Australia
Posts:
25
Plugin Contributions:
0

Re: how to set sideboxes only on mainpage?

I am struggling with this...
for the featured sidebox, I have changed my code to read:
// test if box should display
  $show_featured= true;

// only show if the main page
  if ($this_is_home_page == true) {
    $show_featured= true;
  } else {
    $show_featured= false;
  }
    

changing the "whats_new" above to "featured".

i get the following error on my main page:
Parse error: syntax error, unexpected T_VARIABLE in /home/animalve/public_html/zencart/includes/modules/sideboxes/custom/featured.php on line 13

I also tried following the instructions on page https://www.zen-cart.com/tutorials/index.php?article=270 with the same result.

what am i missing?

7 Jul 2007, 2:38 AM
#8
ajeh avatar

ajeh

Oba-san

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

Re: how to set sideboxes only on mainpage?

What's on lines 10 - 15 on your file?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Jul 2007, 2:52 AM
#9
kmh avatar

kmh

New Zenner

Join Date:
May 2007
Location:
Sydney, Australia
Posts:
25
Plugin Contributions:
0

Re: how to set sideboxes only on mainpage?

first 30 lines are:

<?php /** * featured sidebox - displays a random Featured Product * * @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: featured.php 2808 2006-01-06 17:17:32Z drbyte $ */ // test if box should display   $show_featured= true; // only show if the main page   if ($this_is_home_page == true) {     $show_featured= true;   } else {     $show_featured= false;   } if ($show_featured == true) { $random_featured_products_query = "select p.products_id, p.products_image, pd.products_name from (" . TABLE_PRODUCTS . " p left join " . TABLE_FEATURED . " f on p.products_id = f.products_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id ) where p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' order by pd.products_name desc limit " . MAX_RANDOM_SELECT_FEATURED_PRODUCTS; produces error message: Parse error: syntax error, unexpected T_IF in /home/animalve/public_html/zencart/includes/modules/sideboxes/custom/featured.php on line 15
7 Jul 2007, 3:03 AM
#10
ajeh avatar

ajeh

Oba-san

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

Re: how to set sideboxes only on mainpage?

I cannot seem to break mine based on the code you are displaying ... :unsure:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Jul 2007, 3:04 AM
#11
kmh avatar

kmh

New Zenner

Join Date:
May 2007
Location:
Sydney, Australia
Posts:
25
Plugin Contributions:
0

Re: how to set sideboxes only on mainpage?

bummer, i haven't been able to get it to work on this box or another side box i have.

7 Jul 2007, 3:06 AM
#12
ajeh avatar

ajeh

Oba-san

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

Re: how to set sideboxes only on mainpage?

What are you using for a TEXT editor on these files?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Jul 2007, 10:24 AM
#13
kmh avatar

kmh

New Zenner

Join Date:
May 2007
Location:
Sydney, Australia
Posts:
25
Plugin Contributions:
0

Re: how to set sideboxes only on mainpage?

text wrangler, uploading with cyberduck