turning off left column wipes out home page
I'm trying to turn off both left & right columns for the home page only. Turning off the right column works fine but if I try to also turn off the left column all of the content for the home page is wiped out.
Code I am using:
Code:
if (in_array($current_page_base,explode(",",'index')) ) {
$flag_disable_right = true;
}
if (in_array($current_page_base,explode(",",'index')) ) {
$flag_disable_left = true;
}
I also tried
Code:
if ($this_is_home_page) {
$flag_disable_right = true;
$flag_disable_left = true;
}
What am I doing wrong?
Re: turning off left column wipes out home page
if ($this_is_home_page) {
$flag_disable_right = true;
$flag_disable_left = true;
}
This code is exactly what you should be using, so there must be something else wrong with the editing process.
If you delete or comment out that code and re-save the file, what happens?
Re: turning off left column wipes out home page
The URL where you are trying it?
Re: turning off left column wipes out home page
This is on a test site, it's a completely fresh install with no add on's just stylesheet changes.
The only thing I can get to work is:
if (in_array($current_page_base,explode(",",'index')) ) {
$flag_disable_right = true;
}
Here's a link
I can't understand why such a simple thing isn't working -- obviously a user error :blink:
Here is my tpl_main_page with code to turn off both columns (which doesn't work):
Code:
<?php
/**
* Common Template - tpl_main_page.php
*
* Governs the overall layout of an entire page<br />
* Normally consisting of a header, left side column. center column. right side column and footer<br />
* For customizing, this file can be copied to /templates/your_template_dir/pagename<br />
* example: to override the privacy page<br />
* - make a directory /templates/my_template/privacy<br />
* - copy /templates/templates_defaults/common/tpl_main_page.php to /templates/my_template/privacy/tpl_main_page.php<br />
* <br />
* to override the global settings and turn off columns un-comment the lines below for the correct column to turn off<br />
* to turn off the header and/or footer uncomment the lines below<br />
* Note: header can be disabled in the tpl_header.php<br />
* Note: footer can be disabled in the tpl_footer.php<br />
* <br />
* $flag_disable_header = true;<br />
* $flag_disable_left = true;<br />
* $flag_disable_right = true;<br />
* $flag_disable_footer = true;<br />
* <br />
* // example to not display right column on main page when Always Show Categories is OFF<br />
* <br />
* if ($current_page_base == 'index' and $cPath == '') {<br />
* $flag_disable_right = true;<br />
* }<br />
* <br />
* example to not display right column on main page when Always Show Categories is ON and set to categories_id 3<br />
* <br />
* if ($current_page_base == 'index' and $cPath == '' or $cPath == '3') {<br />
* $flag_disable_right = true;<br />
* }<br />
*
* @package templateSystem
* @copyright Copyright 2003-2007 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: tpl_main_page.php 7085 2007-09-22 04:56:31Z ajeh $
*/
// the following IF statement can be duplicated/modified as needed to set additional flags
if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
$flag_disable_right = true;
}
if ($this_is_home_page) {
$flag_disable_right = true;
$flag_disable_left = true;
}
$header_template = 'tpl_header.php';
$footer_template = 'tpl_footer.php';
$left_column_file = 'column_left.php';
$right_column_file = 'column_right.php';
$body_id = ($this_is_home_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
?>
<body id="<?php echo $body_id . 'Body'; ?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'; ?>>
<?php
if (SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
<div id="mainWrapper">
<?php
/**
* prepares and displays header output
*
*/
if (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_HEADER_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == '')) {
$flag_disable_header = true;
}
require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="contentMainWrapper">
<tr>
<?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) {
?>
<td id="navColumnOne" class="columnLeft" style="width: <?php echo COLUMN_WIDTH_LEFT; ?>">
<?php
/**
* prepares and displays left column sideboxes
*
*/
?>
<div id="navColumnOneWrapper" style="width: <?php echo BOX_WIDTH_LEFT; ?>"><?php require(DIR_WS_MODULES . zen_get_module_directory('column_left.php')); ?></div></td>
<?php
}
?>
<td valign="top">
<!-- bof breadcrumb -->
<?php if (DEFINE_BREADCRUMB_STATUS == '1' || (DEFINE_BREADCRUMB_STATUS == '2' && !$this_is_home_page) ) { ?>
<div id="navBreadCrumb"><?php echo $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR); ?></div>
<?php } ?>
<!-- eof breadcrumb -->
<?php
if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
<!-- bof upload alerts -->
<?php if ($messageStack->size('upload') > 0) echo $messageStack->output('upload'); ?>
<!-- eof upload alerts -->
<?php
/**
* prepares and displays center column
*
*/
require($body_code); ?>
<?php
if (SHOW_BANNERS_GROUP_SET4 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET4)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerFour" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?></td>
<?php
//if (COLUMN_RIGHT_STATUS == 0 || (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == '') || (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_COLUMN_RIGHT_OFF == 'true' && $_SESSION['customers_authorization'] != 0)) {
if (COLUMN_RIGHT_STATUS == 0 || (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == '') || (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_COLUMN_RIGHT_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == ''))) {
// global disable of column_right
$flag_disable_right = true;
}
if (!isset($flag_disable_right) || !$flag_disable_right) {
?>
<td id="navColumnTwo" class="columnRight" style="width: <?php echo COLUMN_WIDTH_RIGHT; ?>">
<?php
/**
* prepares and displays right column sideboxes
*
*/
?>
<div id="navColumnTwoWrapper" style="width: <?php echo BOX_WIDTH_RIGHT; ?>"><?php require(DIR_WS_MODULES . zen_get_module_directory('column_right.php')); ?></div></td>
<?php
}
?>
</tr>
</table>
<?php
/**
* prepares and displays footer output
*
*/
if (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_FOOTER_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == '')) {
$flag_disable_footer = true;
}
require($template->get_template_dir('tpl_footer.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_footer.php');
?>
</div>
<!--bof- parse time display -->
<?php
if (DISPLAY_PAGE_PARSE_TIME == 'true') {
?>
<div class="smallText center">Parse Time: <?php echo $parse_time; ?> - Number of Queries: <?php echo $db->queryCount(); ?> - Query Time: <?php echo $db->queryTime(); ?></div>
<?php
}
?>
<!--eof- parse time display -->
<!--bof- banner #6 display -->
<?php
if (SHOW_BANNERS_GROUP_SET6 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET6)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerSix" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
<!--eof- banner #6 display -->
</body>
Re: turning off left column wipes out home page
I notice that every line of the file you posted is double-spaced, which is a symptom of Notepad editing or possibly some other editor which is not set up to edit files correctly. I don't know why that would cause the homepage code to malfunction, but it couldn't hurt to try it in a proper file editor. What have you been using?
It looks now like the right column is off, but the main content is displaying fine, not cut off like your original post mentioned.
Re: turning off left column wipes out home page
I use Notepad ++. Someone else mentioned the double spacing to me once before. Every zen file I open is double-spaced. I don't know why. I did take out the extra lines but it didn't help (it never seems to make a difference).
Yes, right column poses no problem. It's left column that I need off but I can only turn off right OR left not both.
PS - I have the right column off globally now just to work on the site but I would really like to use it if there's a solution for my problem.
Re: turning off left column wipes out home page
Notepad++ is good, though there may be some obscure setting tripped in your copy that would cause the double spacing. (If you remove the double spaces and save/close the file and upload, does it have double spaces again when you reopen it? Or when you download from your site and reopen?)
The failure of the flag is baffling, since your tpl_main_page.php shows the mechanism in place to use it.
Is your file currently using the "in_array" on just the right column, or the $this_is_home_page on both columns? (I'm not sure which behavior is currently showing.)
Re: turning off left column wipes out home page
Quote:
Originally Posted by
gjh42
Notepad++ is good, though there may be some obscure setting tripped in your copy that would cause the double spacing. (If you remove the double spaces and save/close the file and upload, does it have double spaces again when you reopen it? Or when you download from your site and reopen?)
The failure of the flag is baffling, since your tpl_main_page.php shows the mechanism in place to use it.
Is your file currently using the "in_array" on just the right column, or the $this_is_home_page on both columns? (I'm not sure which behavior is currently showing.)
If I download a page that I removed the double spaces from, they're not there. Just when I initially open the file, even a fresh file from a new install.
Right now, I'm using this:
// the following IF statement can be duplicated/modified as needed to set additional flags
if (in_array($current_page_base,explode(",",'index')) ) {
$flag_disable_left = true;
}
Thanks for your help.
Re: turning off left column wipes out home page
Trying to validate the page to see if there is something missing and there are so many errors being generated by the flash I can't tell what's what. I would guess that you have a mismatched<td> or <tr>
Re: turning off left column wipes out home page
Quote:
Originally Posted by
Kim
Trying to validate the page to see if there is something missing and there are so many errors being generated by the flash I can't tell what's what. I would guess that you have a mismatched<td> or <tr>
hmmm...well that could very well be because I use Expression Web to create my pages. I'll get rid of the flash to check it & see if I can find something. Thanks.
Re: turning off left column wipes out home page
Kim, you must have been right. I deleted my content from the page, just left in some text, validated it and now the code
if ($this_is_home_page) {
$flag_disable_right = true;
$flag_disable_left = true;
}
works :clap:
Now if I can figure out how to get the darn css menu to appear where it's supposed to I'm good to go...
Re: turning off left column wipes out home page
Well, I thought this was fixed but I was wrong. I can still only turn off one column, not both and I have even reinstalled the entire cart. Anyway, I can live with that if I have to but what I'm finding is that any page that acts as a "main" page has no left column, I only want the left column off on the actual home page of the store.
For instance, there is no left column on a category page. How can I fix this so that the left column is only off on the home page of the store?
(yes, I know I now have a bajillion validation errors that are mostly coming from the menu so I am working on that. I had this column error when the page validated also)
TIA
Re: turning off left column wipes out home page
If your files are double spaced it is usually an indication you uploaded the files in Binary mode instead of ASCII.
// the following IF statement can be duplicated/modified as needed to set additional flags
if (in_array($current_page_base,explode(",",'index')) ) {
$flag_disable_left = true;
}
The above code will disable the left column on "every" page because every page uses "index" in the URL.
For the Home page you need to use:
if ($this_is_home_page) {
$flag_disable_right = true;
$flag_disable_left = true;
}
As to your many HTML errors, ditch your Navigation Menu until you can get the bugs worked. Using the above code and switching to the Classic template should verify that your HTML errors are causing problems for the PHP coding.
Re: turning off left column wipes out home page
Thanks Rob. I have deleted the drop menu but now I've got bigger problems. I'll try what you said if I can ever get back into admin :blush:
Re: turning off left column wipes out home page
Believe it or not, on a brand new install with no changes to it at all, the code to turn off both columns didn't work for me. But - in case anyone else wants to do this is having a problem - this did: a combination of the original code to turn off the right column on all index pages & Rob's code to turn off left on home page only.
Unfortunately, I have to reinstall my cart because of this admin problem :censored:
Re: turning off left column wipes out home page
If the basic $this_is_home_page column-off code is not working, there is some problem with your site/host/installation... because those two flags will work as is for a normal installation.
Re: turning off left column wipes out home page
I always install through Fantastico, but since you mention it, I've had feeling for awhile that there is something a little "off" with my hosting servers, or something to do with them. Just little things here and there that are odd, since they did this upgrade several months back.