Forum Moderators: coopster
This has a few functions so let me break it down.
api.php
require_once($theme."/theme.php");
$nbox = new ZoGotable;
class ZoGotable{
function Boxrender($title, $content, $mode="default"){
tablelayout($title, $content, $mode);
}
}
//end table create function
//Render menu's
$mbox = new mentab;
class mentab{
function menurender($title, $content, $mode="default"){
menulayout($title, $content, $mode);
}
}
-------------
Theme.php
define("MENU", "menu.php");
$zheader = "
<table border='0' cellpadding='10' cellspacing='0' style='border-collapse: collapse margin-top: 0; margin-bottom: 0;' class='Body' bordercolor='#111111' width='100%' id='AutoNumber1'>
<tr>
<td width='100%' >
<table border='1' cellpadding='2' cellspacing='0' style='border-collapse: collapse; margin-top: 0; margin-bottom: 0;' bordercolor='#111111' width='100%' id='AutoNumber2' height=100%>
<tr>
<td width='100%' colspan='2' bordercolor='#111111' class='toptit'> Login:
<input type='text' name='T1' size='20'> Password:
<input type='text' name='T2' size='20'>
<input type='Submit' value='Login'>
<a href='themes/images/logo.jpg'>Signup</a></td>
</tr>
<tr>
<td width='100%' colspan='2'>
<img border='0' src='themes/ZoGo/images/logo.jpg' width='600'></td>
</tr>
<tr><td valign=top>".
include(MENU);
$zheader.=" </td> <td width='83%' valign='top' align='center' class='mainbod' rowspan='8' height='100%'>
";
function menulayout($caption, $text){
echo " <table border=1 celpadding=0 cellspacing=0 bordercolor=black><tr> <td width='17%' height='4' bgcolor='#558080' valign='top' class='navcap'>
<p align='center'>caption</b></td></tr>
<tr><td>
<table border=1 cellpadding='0' cellspacing='0' width='100%' bordercolordark='#FFFFFF' bordercolorlight='#000000' class='menulink'>text</table></td>
</tr>
<tr>
<td width='17%' height='1' ' valign='top' class='navcap'>
</td>
</tr></table>
";
}
function tablelayout($caption, $text){
global $style;
//echo "Mode: ".$style;
echo "
<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='90%' id='AutoNumber5' height='199'>
<tr>
<td width='100%' height='27' class='tablecap'>
<p align='center'>$caption</td>
</tr>
<tr>
<td width=100% height='171' class=tablebod><p align='center'>$text<p> </td>
</tr>
</table>
";
}
-------
menu.php
<?php
$title = "Navigation Menu";
$content = "Link 1";
$mbox = new mentab;
$mbox -> menurender($title, $content);
?>
---------
header.php
<?php
echo $zheader;
?>
=====================
Thats the code on each page I then can call these from any page by simply saying (this is my install file)
<?php
require_once("api.php");
require_once("header.php");
$content = "Please Fill in the details below to isntall and configure ZoGo-Cart";
$content .= "<BR><center><table border=1><tr><td colspan=2>HTTP Path to ZoGo folder without Trailing slash '/':</td><td><form action='install.php?step=2' method=Post><input type=text name=path></td></tr>";
$content .= "<tr><td colspan=2>Database host:</td><td><input type=text name=dbhost value=localhost></td></tr>";
$content .= "<tr><td colspan=2>Database Name:</td><td><input type=text name=dbname</td></tr>";
$content .= "<tr><td colspan=2>Database Username:</td><td><input type=text name=dbuser ></td></tr>";
$content.= "<tr><td colspan=2>Database Password:</td><td><input type=text name=dbpwd ></td></tr>";
$content .= "<tr><td colspan=2>Database Prefix:</td><td><input type=text name=dbfix value=ZoGo_></td></tr>";
$content .= "<tr><td colspan=3><center><input type=Submit value='Test Connection'></td></tr>";
$content .= "</table>";
$title = "Welcome to ZoGo-Cart install";
$nbox -> Boxrender($title, $content);
?>
===============================
That should render everything and place it into a standard HEAD, left col and content.
It works if i put all the header and menu code into one file instead of seperating to functions but if left as is it puts a 1 in the left col and puts the folder at the top of the page.
Cheers
Zaphod
You also seem to have some bad HTML in there:
<table border=1 cellpadding='0' cellspacing='0' width='100%' bordercolordark='#FFFFFF' bordercolorlight='#000000' class='menulink'>text</table></td> A <table> tag must always be followed by a <tr> then the cell (either <td> or <th>). You can't have text only inside a table tag as that is meaningless. (Unless you're replacing the text with an include that includes the missing tags?)
The best idea is to let the page run then view the source in the browser. That way you can look for missing tags and simple errors that I know from experience can be hard to spot in PHP, especially when using includes!
Page content within the <table></table> will be rendered PRECEDING the table if it is not included within a cell (<td>here</td> or <th>here</th>). While the end-of-row tag (</tr>) is optional, the others are not.
The effect and final display of the content in this case also depends on the table nesting you have going on. With the exception of the un-contained "text" in your "menulayout" function, it looks like you know all of this.
:)