Forums / Basic Configuration / Sidebox shows only after login

Sidebox shows only after login

Locked

Views: 1,649

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
28 Jun 2007, 7:25 PM
#1
a_1_electronics avatar

a_1_electronics

Inactive

Join Date:
Apr 2007
Posts:
117
Plugin Contributions:
0

Sidebox shows only after login

I would like to make several of my sideboxes to show up only to individuals that are logged in. I would prefer that guests to my site not be able to see these boxes.

Is this possible? And how would I do it?

Thanks for any help.

28 Jun 2007, 7:44 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Sidebox shows only after login

It's both possible and straightforward. Just four simple steps.

  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> // 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> // test if box should display
if (!$_SESSION['customer_id']) {
$show_featured= false;
} else {
$show_featured= true;
}

  1. Upload to your server and enjoy.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

28 Jun 2007, 10:02 PM
#3
a_1_electronics avatar

a_1_electronics

Inactive

Join Date:
Apr 2007
Posts:
117
Plugin Contributions:
0

Re: Sidebox shows only after login

Here is the code. I do not see the //test if box should display. I tried adding it to the begining of the code. That didn't work. I tried changing 'require' to 'if'. That didn't work. It did remove it from the main page but after I logged in, I couldn't see it either. I looked at some of the other php files to try and figure out what I needed to add but I am not a programmer.

This php file is from the Wordpress on Zencart Mod.

<?php // // +----------------------------------------------------------------------+ // |zen-cart Open Source E-commerce | // +----------------------------------------------------------------------+ // | Copyright (c) 2004 The zen-cart developers | // | | // | <http://www.zen-cart.com/index.php> | // | | // | Portions Copyright (c) 2003 osCommerce | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the GPL license, | // | that is bundled with this package in the file LICENSE, and is | // | available through the world-wide-web at the following url: | // | <http://www.zen-cart.com/license/2_0.txt>. | // | If you did not receive a copy of the zen-cart license and are unable | // | to obtain it through the world-wide-web, please send a note to | // | [[email protected]](mailto:"[email protected]") so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ require($template->get_template_dir('tpl_wp_archives.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_wp_archives.php'); $title = BOX_HEADING_WP_ARCHIVES; $left_corner = false; $right_corner = false; $right_arrow = false; $title_link = false; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); ?>
28 Jun 2007, 10:14 PM
#4
ryk avatar

ryk

Totally Zenned

Join Date:
Oct 2004
Location:
Southport, UK
Posts:
3,644
Plugin Contributions:
6

Re: Sidebox shows only after login

Don't forget to change $show_featured to $show_whatever

Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !

28 Jun 2007, 10:18 PM
#5
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Sidebox shows only after login

The problem here is that the sidebox that you're using is not designed for use with Zen Cart 1.3.x. All that $left-corder, $right-corner stuff shows that it was derived from an earlier tables-based version and therefore doesn't follow the proper structure for the current series.

It's not to difficult to update though. Just use one of the current sideboxes as a model.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

2 Jul 2007, 10:19 PM
#6
a_1_electronics avatar

a_1_electronics

Inactive

Join Date:
Apr 2007
Posts:
117
Plugin Contributions:
0

Re: Sidebox shows only after login

Thank you to kuroi and Ryk for your help. I really do appreciate your responses. Due to my lack of programming skills, I had to find additional help in the Wordpress on Zencart thread.

And here is the solution without having to rewrite the code. Thank you misty......

<?php // // +----------------------------------------------------------------------+ // |zen-cart Open Source E-commerce | // +----------------------------------------------------------------------+ // | Copyright (c) 2004 The zen-cart developers | // | | // | [\*\*\[U\]\[COLOR=#0000ff\]http://www.zen-cart.com/index.php\[/COLOR\]\[/U\]\*\*](http://www.zen-cart.com/index.php) | // | | // | Portions Copyright (c) 2003 osCommerce | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the GPL license, | // | that is bundled with this package in the file LICENSE, and is | // | available through the world-wide-web at the following url: | // | [\*\*\[U\]\[COLOR=#0000ff\]http://www.zen-cart.com/license/2\_0.txt\[/COLOR\]\[/U\]\*\*](http://www.zen-cart.com/license/2_0.txt). | // | If you did not receive a copy of the zen-cart license and are unable | // | to obtain it through the world-wide-web, please send a note to | // | license AT zen-cart DOT com so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ require($template->get_template_dir('tpl_wp_archives.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_wp_archives.php'); $title = BOX_HEADING_WP_ARCHIVES; $left_corner = false; $right_corner = false; $right_arrow = false; $title_link = false; //Comment in next line if only registered members can view this sidebox if ($_SESSION['customer_id'] != '') require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); ?>

Please take note of everything from //Comment in next line....

Once again, thank you everyone for your help.