View Full Version : Stuck inserting a php page into html
markhammill
03-18-2008, 05:25 AM
Hi,
I'm trying to insert a php page into my webpage.
I succeeded inserting plaincart shop.php (http://www.michton.com/shop.php) but now I have come to upgrade to zencart I can't seem to do it.
I have attempted it using an inline frame shoptest.php (http://www.michton.com/shoptest.php) it worked in firefox but not IE. I haven't bothered debugging the frame resize as using an inline frame really isn't a route I want to go down.
This is as far as I have got inserting zencart properly shoptest2.php (http://www.michton.com/shoptest2.php)
I guess it is the /store/index.php ( http://www.michton.com/store/index.php
) that is causing the problem.
Here is the /store/index.php code:
<?php
/**
* index.php represents the hub of the Zen Cart MVC system
*
* Overview of flow
* <ul>
* <li>Load application_top.php - see {@tutorial initsystem}</li>
* <li>Set main language directory based on $_SESSION['language']</li>
* <li>Load all *header_php.php files from includes/modules/pages/PAGE_NAME/</li>
* <li>Load html_header.php (this is a common template file)</li>
* <li>Load main_template_vars.php (this is a common template file)</li>
* <li>Load on_load scripts (page based and site wide)</li>
* <li>Load tpl_main_page.php (this is a common template file)</li>
* <li>Load application_bottom.php</li>
* </ul>
*
* @package general
* @copyright Copyright 2003-2005 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: index.php 2942 2006-02-02 04:41:23Z drbyte $
*/
/**
* Load common library stuff
*/
require('includes/application_top.php');
$language_page_directory = DIR_WS_LANGUAGES . $_SESSION['language'] . '/';
$directory_array = $template->get_template_part($code_page_directory, '/^header_php/');
foreach ($directory_array as $value) {
/**
* We now load header code for a given page.
* Page code is stored in includes/modules/pages/PAGE_NAME/directory
* 'header_php.php' files in that directory are loaded now.
*/
require($code_page_directory . '/' . $value);
}
/**
* We now load the html_header.php file. This file contains code that would appear within the HTML <head></head> code
* it is overridable on a template and page basis.
* In that a custom template can define its own common/html_header.php file
*/
require($template->get_template_dir('html_header.php',DIR_WS_TEMPLATE , $current_page_base,'common'). '/html_header.php');
/**
* Define Template Variables picked up from includes/main_template_vars.php unless a file exists in the
* includes/pages/{page_name}/directory to overide. Allowing different pages to have different overall
* templates.
*/
require($template->get_template_dir('main_template_vars.php',DIR_WS_T EMPLATE, $current_page_base,'common'). '/main_template_vars.php');
/**
* Read the "on_load" scripts for the individual page, and from the site-wide template settings
* NOTE: on_load_*.js files must contain just the raw code to be inserted in the <body> tag in the on_load="" parameter.
* Looking in "/includes/modules/pages" for files named "on_load_*.js"
*/
$directory_array = $template->get_template_part(DIR_WS_MODULES . 'pages/' . $current_page_base, '/^on_load_/', '.js');
foreach ($directory_array as $value) {
$onload_file = DIR_WS_MODULES . 'pages/' . $current_page_base . '/' . $value;
$read_contents='';
$lines = @file($onload_file);
foreach($lines as $line) {
$read_contents .= $line;
}
$za_onload_array[] = $read_contents;
}
/**
* now read "includes/templates/TEMPLATE/jscript/on_load/on_load_*.js", which would be site-wide settings
*/
$directory_array=array();
$tpl_dir=$template->get_template_dir('.js', DIR_WS_TEMPLATE, 'jscript/on_load', 'jscript/on_load_');
$directory_array = $template->get_template_part($tpl_dir ,'/^on_load_/', '.js');
foreach ($directory_array as $value) {
$onload_file = $tpl_dir . '/' . $value;
$read_contents='';
$lines = @file($onload_file);
foreach($lines as $line) {
$read_contents .= $line;
}
$za_onload_array[] = $read_contents;
}
// set $zc_first_field for backwards compatibility with previous version usage of this var
if (isset($zc_first_field) && $zc_first_field !='') $za_onload_array[] = $zc_first_field;
$zv_onload = "";
if (isset($za_onload_array) && count($za_onload_array)>0) $zv_onload=implode(';',$za_onload_array);
//ensure we have just one ';' between each, and at the end
$zv_onload = str_replace(';;',';',$zv_onload.';');
// ensure that a blank list is truly blank and thus ignored.
if (trim($zv_onload) == ';') $zv_onload='';
/**
* Define the template that will govern the overall page layout, can be done on a page by page basis
* or using a default template. The default template installed will be a standard 3 column layout. This
* template also loads the page body code based on the variable $body_code.
*/
require($template->get_template_dir('tpl_main_page.php',DIR_WS_TEMPLA TE, $current_page_base,'common'). '/tpl_main_page.php');
?>
</html>
<?php
/**
* Load general code run before page closes
*/
?>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
And here is the important parts of the /shoptest2.php code:
I have removed any php from the top of the page, I don’t know what to put there, I have tried a lot but nothing seems to help.
In the table I have this
<td width="770" height="400" valign="top" bgcolor="#FFFFFF">
<?php include("store/index.php"); ?></td>
</tr>
Thanks in advance
greenman
03-18-2008, 06:50 AM
Looks like you got it working.
I know you probably already know this but this may help someone.
If the parent document is something like 'index.html' try this:
<!--#include virtual="/shop.php" -->
You cannot use <?php ?> in index.html unless you've set the extension to render php in your control panel or .htaccess - not usually recommended.
If the parent document is something like 'index.php' try this:
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/shop.php'); ?>
I've never had much success with include();.
My 2 pfennigs.
markhammill
03-18-2008, 07:05 AM
Hi Greenman,
The one I need to work is the http://www.michton.com/shoptest2.php
It's not working my end.
Could you elaborate on your last post.
I think the php option you explained is the one I should use but I don't know where I should but it.
Should I be adding
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/store/index.php'); ?>
At the top of the shoptest2.php page?
greenman
03-18-2008, 08:10 AM
This is the code that shows up as source. I'm assuming the end of the page is not being rendered because of erroneous php.
update: I suspect the file you want to include is not 'shop.php' but perhaps another file already included in your current 'shop.php' document
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="keywords" content="The Chocolate Factory, Swansea, South Wales, UK, Michton, Chocolate, Marshmallow, Novelty, Sweet, Candy, Manufacturer,
Wholesale, Discount, Wedding Favours, Fred Holts, Chocolate Hearts, Chocolate Balls, Boiled Sweets, Gourmet, Confectionery, Natural Colours, Cardiff,
Chocolate Factory, paypal, trade, foiled chocolates, bespoke, bulk, extruded, deposited, white chocolate, milk chocolate, dark chocolate, belgian
chocolate">
<meta name="description" content="Michton Ltd is a supplier of gourmet chocolate and sugar confectionery. All our products are made in our state
of the art factory in Swansea, which allows us to be a flexible and reliable manufacturer. We only use the highest quality European ingredients
to manufacture our extensive range of products. The types of chocolates we make vary from small, foiled chocolate hearts to huge hollow Easter Eggs.
The types of sugar confectionery we make varies from a wide range of extruded and deposited marshmallow, which we can pack in retail bags, or
in weigh out bags, through to white, brown or coloured candy mice. We also make chocolate (and candy) drops that can be decorated with hundreds
and thousand, in various sizes, colours and flavours.">
<meta name="content" content="Chocolate, Marshmallow, Novelties, Novelty">
<meta name="revisit-after" content="14 days">
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv=expires content=0></meta>
<script src="dbMenu.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="global.css">
<link rel="stylesheet" type="text/css" href="dropDown.css">
<link rel="stylesheet" type="text/css" href="side.css">
<link rel="stylesheet" type="text/css" href="thumbnailviewer.css">
<script src="thumbnailviewer.js" type="text/javascript"></script>
<script type="text/javascript">
/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}
</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3504209-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<link rel="favicon.ico" href="http://www.michton.com/favicon.ico">
</head>
<body bgcolor="#000000" topmargin="0">
<div align="center">
<table border="0" width="770" height="120" id="table4" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" id="table5" cellspacing="0" cellpadding="0" height="120" width="100%" bgcolor="#FFFFFF">
<tr>
<td> <span class="title"><a href="index.htm">MICHTON</a></span></td>
<td>
<p align="right">
<img border="0" src="images/ba.gif" width="360" height="120"></td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" width="770" cellspacing="0" cellpadding="0" id="table12">
<tr>
<td colspan="2" bgcolor="#000000"><span style="font-size: 2pt"> </span></td>
</tr>
<tr>
<td width="0" height="30" valign="top" bgcolor="#FFFFFF"> </td>
<td width="770" height="30" valign="top" bgcolor="#FFFFFF">
<ul id="dropDown" class="dbMenu">
<li><a href="shop.php">
<font style="font-size: 10pt; font-weight: 700"> SHOP</font></a></li>
<li><a href="bespoke.htm"><font style="font-size: 10pt; font-weight: 700"> BESPOKE</font></a></li>
<li><a href="tours.htm"><font style="font-size: 10pt; font-weight: 700"> TOURS</font></a></li>
<li><a href="workshop.htm"><font style="font-size: 10pt; font-weight: 700"> WORKSHOPS</font></a></li>
<li><a href="clubs.htm"><font style="font-size: 10pt; font-weight: 700"> CLUBS</font></a></li>
<li><a href="about.htm"><font style="font-size: 10pt; font-weight: 700"> ABOUT US</font></a></li>
<li><a href="contact.htm"><font style="font-size: 10pt; font-weight: 700">CONTACT US</font></a>
<ul>
<font style="font-size: 9pt; font-weight: 700">
<li><a href="faq.htm">FAQ</a></li>
<li><a href="directions.htm">Directions</a></li>
<li><a href="jobs.htm">Jobs</a></li>
</font>
</ul>
</li>
</ul>
</td>
</tr>
<tr>
<td width="0" valign="top" bgcolor="#000000">
<span style="font-size: 3pt"> </span></td>
<td width="770" valign="top" bgcolor="#000000">
<span style="font-size: 3pt"> </span></td>
</tr>
</table>
<div align="center">
<table width="770" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr valign="top">
<td width="770" height="400" valign="top" bgcolor="#FFFFFF">
After the very last line:
<td width="770" height="400" valign="top" bgcolor="#FFFFFF">
Add this:
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/shop.php'); ?>
The $_SERVER['DOCUMENT_ROOT'] is equivalent to "home/user/public_html" or "/home/user/public_html/domain2.com/" depending whether your domain is the parent domain or an addon. The .'/shop.php' assumes that shop.php is at the root of your domain. If your shop.php is in another web folder, say 'assets', the call would properly be $_SERVER['DOCUMENT_ROOT'].'/assets/shop.php', all within the require_once() call, of course. This way, if you ever need to move to a different host, you don't have to futz around with a bunch of changes in php included files.
Then you need to close out your document and your mysql.
</td>
</tr>
</table>
<table border="0" width="770" cellspacing="0" cellpadding="0" id="table10">
<tr>
<td height="30" valign="bottom">
<span class="sku">Michton
Ltd, Kingsway, Swansea West Ind. Pk., Swansea, SA5 4DL, UK</span></td>
<td height="30" valign="bottom">
<p align="right">
<span class="sku">Copyright Michton Ltd 2008. All rights reserved.</span></td>
</tr>
</table>
</div>
</body>
</html>
<?php mysql_free_result($yourMYSQLcall); ?>
I hope this helps.
markhammill
03-18-2008, 08:53 AM
Still no luck. Here is the full code for what is now http://www.michton.com/shoptest3.php
I have added your changes.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="keywords" content="The Chocolate Factory, Swansea, South Wales, UK, Michton, Chocolate, Marshmallow, Novelty, Sweet, Candy, Manufacturer,
Wholesale, Discount, Wedding Favours, Fred Holts, Chocolate Hearts, Chocolate Balls, Boiled Sweets, Gourmet, Confectionery, Natural Colours, Cardiff,
Chocolate Factory, paypal, trade, foiled chocolates, bespoke, bulk, extruded, deposited, white chocolate, milk chocolate, dark chocolate, belgian
chocolate">
<meta name="description" content="Michton Ltd is a supplier of gourmet chocolate and sugar confectionery. All our products are made in our state
of the art factory in Swansea, which allows us to be a flexible and reliable manufacturer. We only use the highest quality European ingredients
to manufacture our extensive range of products. The types of chocolates we make vary from small, foiled chocolate hearts to huge hollow Easter Eggs.
The types of sugar confectionery we make varies from a wide range of extruded and deposited marshmallow, which we can pack in retail bags, or
in weigh out bags, through to white, brown or coloured candy mice. We also make chocolate (and candy) drops that can be decorated with hundreds
and thousand, in various sizes, colours and flavours.">
<meta name="content" content="Chocolate, Marshmallow, Novelties, Novelty">
<meta name="revisit-after" content="14 days">
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv=expires content=0></meta>
<script src="dbMenu.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="global.css">
<link rel="stylesheet" type="text/css" href="dropDown.css">
<link rel="stylesheet" type="text/css" href="side.css">
<link rel="stylesheet" type="text/css" href="thumbnailviewer.css">
<script src="thumbnailviewer.js" type="text/javascript"></script>
<script type="text/javascript">
/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}
</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3504209-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<link rel="favicon.ico" href="http://www.michton.com/favicon.ico">
</head>
<body bgcolor="#000000" topmargin="0">
<div align="center">
<table border="0" width="770" height="120" id="table4" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" id="table5" cellspacing="0" cellpadding="0" height="120" width="100%" bgcolor="#FFFFFF">
<tr>
<td> <span class="title"><a href="index.htm">MICHTON</a></span></td>
<td>
<p align="right">
<img border="0" src="images/ba.gif" width="360" height="120"></td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" width="770" cellspacing="0" cellpadding="0" id="table12">
<tr>
<td colspan="2" bgcolor="#000000"><span style="font-size: 2pt"> </span></td>
</tr>
<tr>
<td width="0" height="30" valign="top" bgcolor="#FFFFFF"> </td>
<td width="770" height="30" valign="top" bgcolor="#FFFFFF">
<ul id="dropDown" class="dbMenu">
<li><a href="shop.php">
<font style="font-size: 10pt; font-weight: 700"> SHOP</font></a></li>
<li><a href="bespoke.htm"><font style="font-size: 10pt; font-weight: 700"> BESPOKE</font></a></li>
<li><a href="tours.htm"><font style="font-size: 10pt; font-weight: 700"> TOURS</font></a></li>
<li><a href="workshop.htm"><font style="font-size: 10pt; font-weight: 700"> WORKSHOPS</font></a></li>
<li><a href="clubs.htm"><font style="font-size: 10pt; font-weight: 700"> CLUBS</font></a></li>
<li><a href="about.htm"><font style="font-size: 10pt; font-weight: 700"> ABOUT US</font></a></li>
<li><a href="contact.htm"><font style="font-size: 10pt; font-weight: 700">CONTACT US</font></a>
<ul>
<font style="font-size: 9pt; font-weight: 700">
<li><a href="faq.htm">FAQ</a></li>
<li><a href="directions.htm">Directions</a></li>
<li><a href="jobs.htm">Jobs</a></li>
</font>
</ul>
</li>
</ul>
</td>
</tr>
<tr>
<td width="0" valign="top" bgcolor="#000000">
<span style="font-size: 3pt"> </span></td>
<td width="770" valign="top" bgcolor="#000000">
<span style="font-size: 3pt"> </span></td>
</tr>
</table>
<div align="center">
<table width="770" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr valign="top">
<td width="770" height="400" valign="top" bgcolor="#FFFFFF">
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/store/index.php'); ?></td>
</tr>
</table></div>
<table border="0" width="770" cellspacing="0" cellpadding="0" id="table12">
<tr>
<td width="0" valign="top" bgcolor="#000000">
<span style="font-size: 3pt"> </span></td>
<td width="770" valign="top" bgcolor="#000000">
<span style="font-size: 3pt"> </span></td>
</tr>
<tr>
<td width="0" height="30" valign="top" bgcolor="#FFFFFF"> </td>
<td width="770" height="30" valign="top" bgcolor="#FFFFFF">
<ul id="dropDown" class="dbMenu">
<li><font style="font-size: 10pt; font-weight: 700"><a href="trade.htm"> TRADE</a></font></li>
<li><font style="font-size: 10pt; font-weight: 700"><a href="javascript:bookmarksite('Michton Ltd - The Chocolate Factory', 'http://www.michton.com')"> BOOKMARK</a></font></li>
<li><font style="font-size: 10pt; font-weight: 700"><a href="fairtrade.htm"> FAIRTRADE</a></font></li>
<li><font style="font-size: 10pt; font-weight: 700"><a href="ingredients.htm"> INGREDIENTS</a></font></li>
<li><font style="font-size: 10pt; font-weight: 700"><a href="sitemap.htm"> SITE MAP</a></font></li>
<li><font style="font-size: 10pt; font-weight: 700"><a href="links.htm"> LINKS</a></font></li>
<li><font style="font-size: 10pt; font-weight: 700"><a href="terms_and_conditions.htm"> T&Cs</a></font></li>
</ul>
</td>
</tr>
</table>
<table border="0" width="770" cellspacing="0" cellpadding="0" id="table8">
<tr>
<td width="770" valign="top" bgcolor="#000000">
<span style="font-size: 2pt"> </span></td>
</tr>
</table>
<table border="0" width="770" cellspacing="0" cellpadding="0" id="table10">
<tr>
<td height="30" valign="bottom">
<span class="sku">Michton
Ltd, Kingsway, Swansea West Ind. Pk., Swansea, SA5 4DL, UK</span></td>
<td height="30" valign="bottom">
<p align="right">
<span class="sku">Copyright Michton Ltd 2008. All rights reserved.</span></td>
</tr>
</table>
</div>
</body>
</html>
<?php mysql_free_result($yourMYSQLcall); ?>
greenman
03-18-2008, 09:44 AM
Sorry - I was wrong!
Remove those changes, especially the mysql_free_results().
They're probably taken care of from within application_bottom.php.
The error resides in how you are accessing your templating system.
Foolishly, I suggested adding something from outside your templates.
You'll need to fish out where to add edit this from within your templating system.
Sorry I cannot be of more help.
redsox9
03-18-2008, 10:46 AM
Hi, markhamill:
Hey, loved your Stars Wars movies. In any case, without having read through your emails, one suggestion I would have would be to mask a PHP file as an HTML file using .htaccess. You could put your page contents into a PHP file, then add a line to your .htaccess like so:
RewriteRule ^subfolder/file.html /subfolder/file.php
markhammill
04-10-2008, 09:52 AM
Sorry for the very slow reply.
Unfortunately work had me busy with something else.
Thank you all for the help.
I have now got it up and running with most of the bugs ironed out.
Website with new zencart shop and even products (http://www.michton.com)
The only thing I haven't solved is the padding around the cells that appears on the shop page but none of the others.
I will at some stage integrate all of my old pages into the zencart system, but I have about 1000 new products to add to the site which are the priority at the moment.
Thanks again
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.