Zen Cart Logo
Forums / Addon Sideboxes / Put A Zc Sidebox On A Page Outside Zc?

Put A Zc Sidebox On A Page Outside Zc?

Views: 21,138

Results 21 to 40 of 68
15 Apr 2007, 12:15 PM
#21
jla avatar

jla

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

28 May 2007, 6:21 AM
#22
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

28 May 2007, 2:44 PM
#23
ajeh avatar

ajeh

Oba-san

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

Re: Put A Zc Sidebox On A Page Outside Zc?

Sounds like you have space(s) or blank line(s) in your test.php file ...

There are other errors, but start with that one ...

28 May 2007, 4:04 PM
#24
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

28 May 2007, 4:20 PM
#25
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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.

28 May 2007, 4:36 PM
#26
greybeard avatar

greybeard

New Zenner

Join Date:
Mar 2007
Posts:
41
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

30 May 2007, 6:24 AM
#27
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

30 May 2007, 7:27 AM
#28
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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?

30 May 2007, 7:38 AM
#29
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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); 
  }  
  ?>
30 May 2007, 11:50 AM
#30
greybeard avatar

greybeard

New Zenner

Join Date:
Mar 2007
Posts:
41
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

31 May 2007, 7:58 AM
#31
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

3 Jun 2007, 6:14 AM
#32
lisk avatar

lisk

Zen Follower

Join Date:
Jun 2006
Posts:
118
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

I've really hit a brick wall with this blank page thing. Can someone point me in the right direction?

3 Jun 2007, 8:57 AM
#33
billybonds avatar

billybonds

Zen Follower

Join Date:
Nov 2003
Location:
UK
Posts:
102
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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.

13 Jun 2007, 1:23 PM
#34
briohny12 avatar

briohny12

New Zenner

Join Date:
Jun 2007
Posts:
48
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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

14 Jun 2007, 12:17 PM
#35
drbyte avatar

drbyte

Sensei

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

Re: Put A Zc Sidebox On A Page Outside Zc?

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.

14 Jun 2007, 12:28 PM
#36
kuroi avatar

kuroi

Totally Zenned

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

Re: Put A Zc Sidebox On A Page Outside Zc?

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.

15 Jun 2007, 11:40 AM
#37
briohny12 avatar

briohny12

New Zenner

Join Date:
Jun 2007
Posts:
48
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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:

15 Jun 2007, 12:20 PM
#38
kuroi avatar

kuroi

Totally Zenned

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

Re: Put A Zc Sidebox On A Page Outside Zc?

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.

15 Jun 2007, 1:05 PM
#39
briohny12 avatar

briohny12

New Zenner

Join Date:
Jun 2007
Posts:
48
Plugin Contributions:
0

Re: Put A Zc Sidebox On A Page Outside Zc?

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.

15 Jun 2007, 1:09 PM
#40
kuroi avatar

kuroi

Totally Zenned

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

Re: Put A Zc Sidebox On A Page Outside Zc?

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.