Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Feb 2007
    Posts
    1
    Plugin Contributions
    0

    Default 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

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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!

  3. #3
    Join Date
    May 2007
    Posts
    27
    Plugin Contributions
    0

    Default 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

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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:
    PHP Code:
    // 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() > ) {
        
    $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_defaultDIR_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:
    PHP Code:
    // test if box should display
      
    $show_whats_newtrue;

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

    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() > ) {
        
    $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_defaultDIR_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!

  5. #5
    Join Date
    May 2007
    Posts
    17
    Plugin Contributions
    0

    Default 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

  6. #6
    Join Date
    May 2007
    Posts
    17
    Plugin Contributions
    0

    Default 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. #7
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    25
    Plugin Contributions
    0

    Default 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/i...hp?article=270 with the same result.

    what am i missing?

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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!

  9. #9
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    25
    Plugin Contributions
    0

    Default 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 $
    */

    //&#160;test&#160;if&#160;box&#160;should&#160;display
    &#160;&#160;$show_featured= true;

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

    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
    Last edited by kmh; 7 Jul 2007 at 03:53 AM. Reason: clarity

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: how to set sideboxes only on mainpage?

    I cannot seem to break mine based on the code you are displaying ...
    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!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Set items only to Ireland.... How??
    By kitcorsa in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 27 Mar 2014, 01:24 PM
  2. Changing background colour of mainpage wrapper only
    By g3steve in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 9 Sep 2009, 10:33 PM
  3. How to make sideboxes show up on certain pages only?
    By Meshach in forum Basic Configuration
    Replies: 15
    Last Post: 28 Aug 2008, 05:08 PM
  4. featured product only shows on the mainpage
    By JimmyV in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 24 Feb 2008, 05:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg