Thanks for the link to tidy. I am going to check it out tomorrow cause is getting late now.
To clear some things out, I am posting my whole code.
My aim is to make a website which will be easily updateable. No need to write html code, placing images etc. Just create a word, pdf etc document with the updated content plus images and then upload it to the server.
This is the page layout:
INDEX.PHP
<?php
require_once("class.php");
if(!isset($fpage))
{
$fpage = "news.php";
}
else {
$fpage ;
}
$page = new Page("template.html");
$page->replace_tags(array(
"title"=>"Hoav Website",
"contenthd"=>"Anouncements",
"content" => $fpage,
"navbar" => "board2.htm",
));
$page->output();
?>
END INDEX.PHP
BEGIN CLASS.PHP
<?php
class Page
{
var $page;
function Page($template = "template.html") {
if (file_exists($template))
$this->page = join("", file($template));
else
die("Template file $template not found.");
}
function parse($file) {
ob_start();
include($file);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
function replace_tags($tags = array()) {
if (sizeof($tags) > 0)
foreach ($tags as $tag => $data) {
$data = (file_exists($data))? $this->parse($data) : $data;
$this->page = eregi_replace("{" .$tag. "}", $data,
$this->page);
}
else
die("No tags designated for replacement.");
}
function output() {
echo $this->page;
}
}
?>
END CLASS.PHP
BEGIN TEST.CSS
#body {margin:0px;
background-color: #336699;
overflow:auto;
}
#main {
width:100%;
vertical-align: top;
height:100%;
border: none;
overflow:scroll;
}
#head {
background-image:url('head.jpg') ;
background-repeat:repeat-x;
height:60px;
position: relative;
}
#navbar {
width: 20%;
background-color:#336699 ;
vertical-align:top;
border:solid 2px #336699;
}
#content {
width: 80%;
background-color:#003366;
vertical-align:top;
border:solid 5px #000000;
text-align: center;
color:#FFFFCC;
font-size: 35px;
font-family: serif;
overflow: scroll;
font-weight: bold;
}
#p {
color:#ffff99;
font-size: 15px;
text-align: left;
font-family: serif;
font-weight: lighter;
padding-left: 5%;
}
END TEST.CSS
BEGIN TEMPLATE.HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>{title}</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="test.css" />
</head>
<body id="body">
<table id="main" cellpadding="0" cellspacing="0" >
<tr>
<td id="head" colspan="2">{head}</td>
</tr>
<tr>
<td id="navbar">{navbar}
</td>
<td id="content">{contenthd} <p id="p">
{content}
</p>
</td>
</tr>
</table>
</body>
</html>
END TEMPLATE.HTML
BEGIN NEWS.PHP
<?
$file = 'news.txt';
$data = file($file) or die('Could not read file!');
foreach ($data as $line) {
echo nl2br($line);
};
?>
END NEWS.PHP
BEGIN TAE.PHP
<?
header('Content-Type: text/html');
$file = 'TAE/tae2.htm';
$data = file($file) or die('Could not read file!');
foreach ($data as $line) {
echo nl2br($line);
};
?>
END TAE.PHP
Sorry for the long post, but now you can have an overview of my project.
Good night and thank you for your efforts.
babil