Zen Follower
- Join Date:
- Jul 2005
- Posts:
- 128
- Plugin Contributions:
- 0
Put A Zc Sidebox On A Page Outside Zc?
Sorry but we did all of this on a Windows box so not sure we might be able to help with this...
Views: 21,138
Zen Follower
Sorry but we did all of this on a Windows box so not sure we might be able to help with this...
Zen Follower
I think things must have changed since this solution was posted, because when I try to call the single_sidebox.php from an otherwise blank php file in the root directory of my site, I get these errors:
Warning: Cannot modify header information - headers already sent by (output started at /home/liskidde/public_html/dichroicjewelry/test.php:9) in /home/liskidde/public_html/dichroicjewelry/glass/includes/application_top.php on line 62
Warning: Cannot modify header information - headers already sent by (output started at /home/liskidde/public_html/dichroicjewelry/test.php:9) in /home/liskidde/public_html/dichroicjewelry/glass/includes/application_top.php on line 67
Warning: include(DIR_WS_INCLUDESauto_loaders/config.core.php) [function.include]: failed to open stream: No such file or directory in /home/liskidde/public_html/dichroicjewelry/glass/includes/application_top.php on line 90
Warning: include() [function.include]: Failed opening 'DIR_WS_INCLUDESauto_loaders/config.core.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/liskidde/public_html/dichroicjewelry/glass/includes/application_top.php on line 90
Warning: dir(DIR_WS_INCLUDESauto_loaders) [function.dir]: failed to open dir: No such file or directory in /home/liskidde/public_html/dichroicjewelry/glass/includes/application_top.php on line 91
Warning: Cannot modify header information - headers already sent by (output started at /home/liskidde/public_html/dichroicjewelry/test.php:9) in /home/liskidde/public_html/dichroicjewelry/glass/includes/application_top.php on line 112
Can someone help me adapt the code provided in this thread? I'd like to put my featured products in the sidebar of my blog, which is in the root directory of my site.
Blog: http://dichroicjewelry.net
Store: http://dichroicjewelry.net/glass
Oba-san
Sounds like you have space(s) or blank line(s) in your test.php file ...
There are other errors, but start with that one ...
Zen Follower
That doesn't seem to have changed any of the errors. Here's the code:
<?php
/**
* single_sidebox.php used to display a Zen Cart sidebox on some external resource
*
* @package general
* @copyright Copyright 2003-2006 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: single_sidebox.php based on index.php 2942 2006-02-02 04:41:23Z drbyte $
*/
/**
* Load common library stuff
*/
require('includes/application_top.php');
/**
* PLEASE ENTER THE NAME OF THE SIDEBOX YOU WANT TO CALL HERE:
*/
$sidebox_name = 'featured.php';
//which sidebox template to use:
$column_box_default='tpl_box_default_left.php';
$column_width = BOX_WIDTH_LEFT;
/**
* Load required functions and processing to generate the sidebox:
*/
$language_page_directory = DIR_WS_LANGUAGES . $_SESSION['language'] . '/';
$box_id = zen_get_box_id($sidebox_name);
if ( file_exists(DIR_WS_MODULES . 'sideboxes/' . $template_dir . '/' . $sidebox_name) ) {
require(DIR_WS_MODULES . 'sideboxes/' . $template_dir . '/' . $sidebox_name);
} else {
require(DIR_WS_MODULES . 'sideboxes/' . $sidebox_name);
}
/**
* Load general code which runs before page closes
*/
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
I'm getting the same errors. I'm wondering if maybe Zen Cart was restructured between when this code was written and today, such that the paths are now off or something...
Zen Follower
Okay, the problem was that I had <? require('glass/test.php'); ?> inside a normal page, like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body><? require('glass/test.php'); ?>
</body>
</html>
Once I took it out I stopped getting those errors, but now I'm getting:
Not Found
The requested URL /zc_install/index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
New Zenner
I was getting the header already sent problem. so i made a copy of application_top.php and called it application_topb.php.
Then i updated all the links so that they had /store/ in front of them, this stopped me getting the header problem because it was trying to send me to the install file becuase it couldnt find the configure files.
But the next problem is that i get:
Fatal error: Call to a member function Execute() on a non-object in E:\Program Files\Apache Group\Apache2\htdocs\studiocare\html\store\includes\classes\currencies.php on line **31
**So i have looked my my categories.php, currencies.php, application_top.php and auto_loaders.php and cant find anything to help woth this. I feel like im getting close...
Zen Follower
Greybeard:
Then i updated all the links so that they had /store/ in front of them, this stopped me getting the header problem because it was trying to send me to the install file becuase it couldnt find the configure files.
You updated all of the links in which file? single_sidebox.php or application_topb.php? I'm having trouble getting this far - I keep getting sent to the missing install file.
I think my main problem is conceptually, I can't figure out what my point of reference is. My store works like this: http://blog.com/store - I am trying to get single_sidebox.php to show up in my blog. But I can't figure out if my point of reference is the blog, where I'm putting the "require" php code, or if it is the single_sidebox.php file in the store, so I'm having trouble with the paths (I'm sorry if this is making no sense - I'm not a php programmer AT ALL).
Zen Follower
Greybeard:
But the next problem is that i get:
Fatal error: Call to a member function Execute() on a non-object in E:\Program Files\Apache Group\Apache2\htdocs\studiocare\html\store\includes\classes\currencies.php on line [B]31
Okay I screwed around with this until I got to the point of getting this error, and I made it go away with the PHP 5.2.0 bug workaround:
<?
// Return a random row from a database query
function zen_random_select($query) {
global $db;
if (!is_object($db)) {
//PHP 5.2.0 bug workaround ...
$db = new queryFactory();
$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false);
$random_product = '';
$random_query = $db->Execute($query);
$num_rows = $random_query->RecordCount();
if ($num_rows > 1) {
$random_row = zen_rand(0, ($num_rows - 1));
$random_query->Move($random_row);
}
}
}
return $random_query;
require('blogfiles/application_topb.php');
require('includes/modules/sideboxes/featured.php');
?>
Buuuuuuuuuut now I have a blank page. Hmmmmm.... am I calling the wrong file?
Zen Follower
Adding these changes to DrByte's code is also resulting in a blank page. Anyone have any ideas? Here's code #2:
<?
require('blogfiles/application_topb.php');
// Return a random row from a database query
function zen_random_select($query) {
global $db;
if (!is_object($db)) {
//PHP 5.2.0 bug workaround ...
$db = new queryFactory();
$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false);
$random_product = '';
$random_query = $db->Execute($query);
$num_rows = $random_query->RecordCount();
if ($num_rows > 1) {
$random_row = zen_rand(0, ($num_rows - 1));
$random_query->Move($random_row);
}
}
}
return $random_query;
$sidebox_name = 'featured.php';
//which sidebox template to use:
$column_box_default='tpl_box_default_left.php';
$column_width = BOX_WIDTH_LEFT;
/**
* Load required functions and processing to generate the sidebox:
*/
$language_page_directory = DIR_WS_LANGUAGES . $_SESSION['language'] . '/';
$box_id = zen_get_box_id($sidebox_name);
if ( file_exists(DIR_WS_MODULES . 'sideboxes/' . $template_dir . '/' . $sidebox_name) ) {
require(DIR_WS_MODULES . 'sideboxes/' . $template_dir . '/' . $sidebox_name);
} else {
require(DIR_WS_MODULES . 'sideboxes/' . $sidebox_name);
}
?>
New Zenner
I changed the paths in application_topb.php which it looks liek you have done too lisk.
What files is the code from that you just posted, and whats the bug work around?
This is hard...
Rob
Zen Follower
It's DrByte's single_sidebox.php file posted on page 1 of this thread (third post).
The php 5.2.0 bugfix is what fixed the error problem for me: http://www.zen-cart.com/forum/showthread.php?t=50534&page=3 (post #26)
I can't seem to get past the blank page problem...
Zen Follower
I've really hit a brick wall with this blank page thing. Can someone point me in the right direction?
Zen Follower
Figster:
I am trying this, I get most of the box just below theses errors:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home2/bigjim/public_html/HotStuffLeatherandLaceMediaPage.php:8) in /home2/bigjim/public_html/includes/functions/sessions.php on line 108
Warning: Cannot modify header information - headers already sent by (output started at /home2/bigjim/public_html/HotStuffLeatherandLaceMediaPage.php:8) in /home2/bigjim/public_html/includes/init_includes/init_templates.php on line 78
Any idea what I did wrong?
Thanks,
I have the same problem. Anybody?
Thanks.
New Zenner
Hi,
I followed Dr Byte's single_sidebox.php code and it works fine... except for the formatting. How do I include the same ZenCart side box formatting for this page?
Thanks
Sensei
It doesn't bring any of your CSS definitions forward for display. You have to do that yourself.
But it does build all the tags used in the box as if it was on your main store area.
So, all you need to do is copy the relevant styles from your Zen Cart stylesheet into the stylesheet used on whatever page you'll be using to display the content.
You can see the styles used by looking at the raw HTML generated in your browser by bringing up the sidebox with the link you gave, and looking at View Source.
Totally Zenned
This post gives a good methodology for identifying the styles that may be used by your sidebox, except that instead of tweaking them in your stylesheet, you would be extracting them to add to the stylesheet for the site where you have your external sidebox.
New Zenner
Thanks DrByte / Kuroi,
I brought in the CSS styling into the php file. It's styling fine now except the warning error headers are now appearing.
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at D:\inetpub\surfworld\onlineshop\whats_new.php:239) in D:\inetpub\surfworld\onlineshop\includes\functions\sessions.php on line 108
Warning: Cannot modify header information - headers already sent by (output started at D:\inetpub\surfworld\onlineshop\whats_new.php:239) in D:\inetpub\surfworld\onlineshop\includes\init_includes\init_templates.php on line 78
I checked that post that you recommended DrByte about the white spaces (https://www.zen-cart.com/tutorials/index.php?article=87). I checked the error lines and the code, there doesn't seem to be any white spaces.
I only have CSS and then the <?php require ('single_sidebox.php'); ?> code within the page that I'm trying to call. The errors are referring to parts of the CSS code.
Here is the page again...
http://www.surfworldireland.com/onlineshop/whats_new.php
Any other ideas what could be causing the header warning messages.
Thanks again for your help. :smile:
Totally Zenned
The problem is happening because your are sending information to the browser window prior to starting a session (which is done by the inclusion of application_top.php). A possible way to avoid this would be to cosy the <?php tag right up to the closing </style> tag, i.e. same line and no space between. But it may be better to go straight to the situation where you actually want to use the sidebox, since that's the environment in which it really needs to play nicely, and solving this in isolation in a document without the normal HTML structures won't necessarily tell you anything about whether it will work where you really want it to.
New Zenner
Thanks Kuroi.
I tried pulling the .php tag all the way up to the end of the </style> tag but with no luck.
I also tried calling the .php code from within the html environment but it brought up the same errors. It keeps pulling up errors within the CSS code within the <style></style> tags.
Totally Zenned
I guess the styles are still being treated as output to the browser, even though they're not displayed. I should have thought of that. Instead then, I recommend pulling the require('includes/application_top.php'); statement out, wrapping php tags around it i.e.> <?php require('includes/application_top.php'); ?>and making it the very first thing in your file.
Tell staff why this post should be reviewed.