Results 1 to 10 of 16

Hybrid View

  1. #1
    Join Date
    Apr 2004
    Location
    UK
    Posts
    5,821
    Plugin Contributions
    2

    Default Re: Hide Column Left does not work

    If you wish to disable certain sideboxes only to non members then
    https://www.zen-cart.com/tutorials/i...hp?article=279
    should help..

  2. #2
    Join Date
    Sep 2007
    Location
    Croatia
    Posts
    8
    Plugin Contributions
    0

    Default Re: Hide Column Left does not work

    Quote Originally Posted by misty View Post
    If you wish to disable certain sideboxes only to non members then
    https://www.zen-cart.com/tutorials/i...hp?article=279
    should help..
    With this tutorial I can hide from registered users following sideboxes:
    • banner_box.php
    • banner_box2.php
    • banner_box_all.php
    • best_sellers.php
    • currencies.php
    • featured.php
    • languages.php
    • manufacturers.php
    • product_notifications.php
    • search_header.php
    • shopping_cart.php
    • specials.php
    • tell_a_friend.php
    • whos_online.php


    How do I hide categories.php, ezpages.php and information.php since they do not contain $show_XY?

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

    Default Re: I want to hide the left column for not-logged-in visitors

    To control a sidebox and when it displays you are just needing to stop the code from running in the:
    /includes/modules/sideboxes/blah_blah.php
    /includes/templates/templates_default/sideboxes/blah_blah.php

    file that has the code ...

    I prefer to copy both peices of a sidebox to the overrides to avoid confusion on what is customized and what is not ...
    /includes/modules/sideboxes/your_template_dir/blah_blah.php
    /includes/templates/your_template_dir/sideboxes/blah_blah.php

    To manage the control of the code, you customize the file:
    /includes/modules/sideboxes/your_template_dir/blah_blah.php

    For example, look at the
    /includes/modules/sideboxes/tell_a_friend.php

    code and how that is constructed:
    Code:
    // test if box should display
      $show_tell_a_friend= false;
    
      if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
        if (!($_GET['main_page']==FILENAME_TELL_A_FRIEND)) $show_tell_a_friend = true;
      }
    
      if ($show_tell_a_friend == true) {
        require($template->get_template_dir('tpl_tell_a_friend.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_tell_a_friend.php');
        $title =  BOX_HEADING_TELL_A_FRIEND;
    
        $title_link = false;
        require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
      }
    
    The IF statement has a variable $show_tell_a_friend which when true allows the code to run ... when false the code will not run and the sidebox is disabled, even though it is set to run in the Layout Boxes Controller ...

    To manage any other sidebox, you do the same thing where you set a variable with a condition to set true or false and then use that variable to run the code or not ...

    Many sideboxes already have a variable set as they have conditions as part of the original code ...

    Those sideboxes that do not have a variable can, but simply adding the variable and the conditions to set it to true or false and then surrounding the code with an IF that lets the code run or not based on that condition ...

    The categories sidebox:
    /includes/modules/sideboxes/categories.php

    has the code:
    Code:
        $main_category_tree = new category_tree;
        $row = 0;
        $box_categories_array = array();
    
    // don't build a tree when no categories
        $check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
        if ($check_categories->RecordCount() > 0) {
          $box_categories_array = $main_category_tree->zen_category_tree();
        }
    
        require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
    
        $title = BOX_HEADING_CATEGORIES;
        $title_link = false;
    
        require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    There isn't, by default, a variable set to control the condition of when to run this, so one needs to be added and the IF needs to be added to control the code ...
    Code:
    // test if box should display
      $show_categories= false;
    
    if (something_happens_here) {
      // run the code
        $show_categories= true;
    } else {
    // do not run the code
      $show_categories= false;
    }  
    
    if ($show_categories == true) {
        $main_category_tree = new category_tree;
        $row = 0;
        $box_categories_array = array();
    
    // don't build a tree when no categories
        $check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
        if ($check_categories->RecordCount() > 0) {
          $box_categories_array = $main_category_tree->zen_category_tree();
        }
    
        require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
    
        $title = BOX_HEADING_CATEGORIES;
        $title_link = false;
    
        require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }   
    Again, follow the use of the templates and overrides to make life easier on future upgrades ...

    Easy smeazy, eh?
    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!

  4. #4
    Join Date
    Sep 2007
    Location
    Croatia
    Posts
    8
    Plugin Contributions
    0

    Default Re: I want to hide the left column for not-logged-in visitors

    I copied categories.php to /includes/modules/sideboxes/MY_TEMPLATE/ and entered code:

    Code:
    $show_categories= false;
    
    if (!$_SESSION['customer_id']) {
      // run the code
        $show_categories= true;
    } else {
    // do not run the code
      $show_categories= false;
    }  
    
    if ($show_categories == true) {
    
    <!-- REST OF THE ORIGINAL FILE -->
    
    }
    and category is still visable in the column.

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

    Default Re: I want to hide the left column for not-logged-in visitors

    While your IF should work fine, and your code does work on my site, I prefer to use:
    Code:
    $show_categories= false;
    
    if ($_SESSION['customer_id'] == 0) {
      // run the code
        $show_categories= true;
    } else {
    // do not run the code
      $show_categories= false;
    }
    
    if ($show_categories == true) {
        $main_category_tree = new category_tree;
        $row = 0;
        $box_categories_array = array();
    
    // don't build a tree when no categories
        $check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
        if ($check_categories->RecordCount() > 0) {
          $box_categories_array = $main_category_tree->zen_category_tree();
        }
    
        require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
    
        $title = BOX_HEADING_CATEGORIES;
        $title_link = false;
    
        require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
    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!

  6. #6
    Join Date
    Sep 2007
    Location
    Croatia
    Posts
    8
    Plugin Contributions
    0

    Default Re: I want to hide the left column for not-logged-in visitors

    Yes, it works with
    Code:
    if ($_SESSION['customer_id'] == 0)
    Final question :)
    If I wish to hide whole left column from unregistered customers can I do it with this code and where do I need to implement it?

    I tried to modifty tpl_main_page.php and the following code
    Code:
    <?php
    
    if (COLUMN_LEFT_STATUS == 0 || (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == '') || (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_COLUMN_LEFT_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == ''))) {
      // global disable of column_left
      $flag_disable_left = true;
    }
    if (!isset($flag_disable_left) || !$flag_disable_left) {
    
    ?>
    and combine it with the code which we used for categories.php, but I had no result.

  7. #7
    Join Date
    Apr 2004
    Location
    UK
    Posts
    5,821
    Plugin Contributions
    2

    Default Re: I want to hide the left column for not-logged-in visitors

    Try
    Code:
    <?php
    if ($_SESSION['customer_id'] == 0){
      // global disable of column_left
      $flag_disable_left = true;
    }
    ?>

 

 

Similar Threads

  1. Not working: Customer Authorization: Hide Column Left ?
    By seanzhu in forum Customization from the Admin
    Replies: 2
    Last Post: 7 Sep 2010, 12:00 PM
  2. Want to all subcategies in left column
    By Player in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 31 Aug 2010, 11:03 AM
  3. Hide Column Left switch does not work
    By sfatula in forum Bug Reports
    Replies: 2
    Last Post: 27 Sep 2006, 07:43 PM
  4. Hide Column Left doesn't work?
    By sfatula in forum General Questions
    Replies: 4
    Last Post: 27 Sep 2006, 05:50 PM

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