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.
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.
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 toThese 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
$show_featured= true;4. Upload to your server and enjoy.// test if box should display
if (!$_SESSION['customer_id']) {
$show_featured= false;
} else {
$show_featured= true;
}
Kuroi Web Design and Development | Twitter
(Questions answered in the forum only - so that any forum member can benefit - not by personal message)
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 |
// | 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;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
?>
Don't forget to change $show_featured to $show_whatever
Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !
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)
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 |
// | |
// | 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 |
// | 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.