Forums / General Questions / I want to hide the left column for not-logged-in visitors

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

Locked

Started by oluja on 20 Mar 2009, 1:53 AM · Views: 2,270

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
20 Mar 2009, 1:53 AM
#1
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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

Hello, I'm trying to hide left column (category, ez pages, info etc.) from the non-registered users, but it is not working.

Searching the forum about this subject I found similar topic which is also unresolved, so I tought to report the problem.

I am using fresh ZC v1.3.8a install with no addons.

My Admin > Configuration > Customer details are following:

  • Customer Shop Status - View Shop and Prices = 2
  • Customer Approval Status - Authorization Pending = 2
  • Customer Authorization: filename = customers_authorization
  • Customer Authorization: Hide Column Left = true
20 Mar 2009, 4:34 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

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

Can you explain a little more about the "why" behind wanting to do the hiding?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

20 Mar 2009, 6:02 AM
#3
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

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

Add code below to stylesheet of CURRENT Template

#navColumnOne {display:none}

Dezina ZenCart Templates
Please do not PM for support queries..Post in forums..help others

20 Mar 2009, 6:05 AM
#4
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

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

Add code below to stylesheet of CURRENT Template

#navColumnOne {display:none}

Dezina ZenCart Templates
Please do not PM for support queries..Post in forums..help others

21 Mar 2009, 10:24 PM
#5
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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

DrByte:

Can you explain a little more about the "why" behind wanting to do the hiding?

I am creating a t-shirt web-shop. My intention is to show category items, gallery, detail information etc. only to the registered users. On the main page non-registered users will see only featured products and banner for something like: "Why not register? Unlock / see / view all t-shirts, check out the gallery of our customers, review products, ... "

21 Mar 2009, 10:29 PM
#6
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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

misty:

Add code below to stylesheet of CURRENT Template

#navColumnOne {display:none}


Thank you misty for the comment but this will completely remove the column from the template. My wish is to hide the columns from the non-registered users and make it visible only when they register.
22 Mar 2009, 7:39 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

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

Moderator Note: Since this discussion has digressed from the alleged bug report aspect, it has been moved to a different forum category for further discussion.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Mar 2009, 12:21 PM
#9
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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

misty:

If you wish to disable certain sideboxes only to non members then
https://www.zen-cart.com/tutorials/index.php?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?

22 Mar 2009, 1:53 PM
#10
ajeh avatar

ajeh

Oba-san

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

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:

// 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:

    $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 ...

// 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? :cool:

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!

22 Mar 2009, 11:19 PM
#11
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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:

$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.

23 Mar 2009, 3:09 AM
#12
ajeh avatar

ajeh

Oba-san

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

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:

$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);
[B]}[/B]

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!

23 Mar 2009, 11:15 AM
#13
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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

Yes, it works with ```
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```
<?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.

23 Mar 2009, 11:26 AM
#14
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

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

Try

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

Dezina ZenCart Templates
Please do not PM for support queries..Post in forums..help others

23 Mar 2009, 12:43 PM
#15
oluja avatar

oluja

New Zenner

Join Date:
Sep 2007
Location:
Croatia
Posts:
8
Plugin Contributions:
0

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

When I replace in tpl_main_page.php

<?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) {
?>

with following code:

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

it works.

Thank you, everbody!! :hug:

23 Mar 2009, 1:51 PM
#16
ajeh avatar

ajeh

Oba-san

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

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

It would be better to add your code under the original code:

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 ($_SESSION['customer_id'] == 0){
  // disable column_left if customer is not logged in
  $flag_disable_left = true;
}

This way, the other features can still work if needed ...

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!