ok, I been working a template system.
My index.php has this
<?php
require 'pages/template.html';
$path = 'pages/';
$extension = '.html';
if ( preg_match("#[a-z0-9_]+$#i",$page) ){
$filename = $path.$page.$extension;
include($filename);
}
?>
The script above call the master page template.html which works fine.
It also works great when I hard core the links i.e. ?page=about
Now in the center of the template I left open for content. What I am trying to do is call the content by links using a PHP call tag.
If the index.php page is call I want it to load the main.html content, but if a person select a diffrent link " ?page=about" I would like it to replace the main.html file with the about.html
I tried this which did not work.
<?
// error_reporting(0);
if(!$file=fopen("$page.html", "r")) {
//error_reporting(E_ALL ^ E_NOTICE);
echo "Sorry, the page you tried to access could not be found on the server";
} else {
include("$page.html");
}
?>
I thought it would work, but I am wrong... 🙁
Can anybody help me with the php tag needed for the template page so that it calls the main.html when index.php is called but will switch when another link is called....
Also there is no DB being used, it just calls another html file from a folder named pages.
sincerely,
Robert