Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    2
    Plugin Contributions
    0

    Default sidebox module for logged in users only

    I am modifying a store to only be available to employees at a company. The purpose is for the employee to be able to order company work clothes only available to them, not to the public. I need to be able to suppress side boxes, unless the employee is logged in as a customer. I have found this tutorial: https://www.zen-cart.com/tutorials/i...hp?article=279 which states:
    1. Locate the module for the sidebox (or boxes) that you want to treat like this. You'll find them in includes/modules/sideboxes.

    2. Create over-ride files for them by copying them to includes/modules/sideboxes/YOUR_TEMPLATE_NAME.

    3. Open the over-ride file and find a couple of lines that look similar to:
    Code:
    // test if box should display
    $show_featured= true;
    These were taken from the featured_products products sidebox and the variable name for your box will probably differ slightly. Then change them to:
    Code:
    // test if box should display
    if (!$_SESSION['customer_id']) {
    $show_featured= false;
    } else {
    $show_featured= true;
    }
    I am trying to modify the catagories sidebox but I cant find any thing similar to step 3 in categories.php.
    I am using zen-cart-v1.3.9
    Here is the code for sideboxes/custom/categories.php:
    Code:
    <?php
    /**
     * categories sidebox - prepares content for the main categories sidebox
     *
     * @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: categories.php 2718 2005-12-28 06:42:39Z drbyte $
     */
    	$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);
    ?>
    I tried adding this to the top, but with no success:
    Code:
    if (!$_SESSION['customer_id']) {
    $show_categories_array= false;
    } else {
    $show_categories_array= true;
    }
    Thanks for your time.

  2. #2
    Join Date
    May 2010
    Location
    Cyberspace
    Posts
    376
    Plugin Contributions
    0

    Default Re: sidebox module for logged in users only

    i) create the following file: login.css

    ii) copy the following code to login.css

    #navColumnOne {display:none;}
    #navColumnTwo {display:none;}
    #navBreadCrumb {display:none;}


    iii) upload login.css to includes/templates/YOUR_TEMPLATE/css

    iv) in Admin --> Configuration --> Customer Details --> set Customer Shop Status - View Shop and Prices to 1.

    Voila!

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

    Default Re: sidebox module for logged in users only

    The way the IF statement works in the Featured Sidebox is that there is an IF surrounding the code in the featured.php file ...

    That IF has the code:
    Code:
      if ($show_featured == true) {
    above that code you can add:
    Code:
    // test if box should display
    if (!$_SESSION['customer_id']) {
    $show_featured= false;
    } else {
    $show_featured= true;
    }
    that sets the variable:
    $show_featured

    to true or false based on the test for the whether the customer is logged in or not based on:
    Code:
    if (!$_SESSION['customer_id']) {
    You can do the same thing in any other sidebox, but you have to have two things:

    1 customize the code for the test, such as:
    Code:
    // test if box should display
    if (!$_SESSION['customer_id']) {
    $show_categories= false;
    } else {
    $show_categories= true;
    }
    2 add the IF to use the results:
    Code:
      if ($show_categories == true) {
    around the code and do not forget the closing bracket on the IF at the bottom of the 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!

  4. #4
    Join Date
    Apr 2011
    Posts
    2
    Plugin Contributions
    0

    Default Re: sidebox module for logged in users only

    Thank you for all your help. I used Soniccc's solution and it worked perfectly.

 

 

Similar Threads

  1. Specials Box only for logged in users
    By Jace in forum General Questions
    Replies: 6
    Last Post: 30 Sep 2011, 01:57 PM
  2. Persistent header links across CMS' for seamless logged in users?
    By swamyg1 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 28 Mar 2011, 10:09 AM
  3. Replies: 4
    Last Post: 5 Jun 2010, 01:44 PM
  4. Adding a PDF file accessible only to logged in users
    By Heyzoos in forum General Questions
    Replies: 1
    Last Post: 30 Aug 2007, 05:55 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