some of the variables and directories are in croatian, but i don't think that matters when you look at with programmers eyes.
First my index.php file looks like this...
CODE
<?php include ("includes/showSiteClass.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jednostavno.com - Jednostavno o Web dizajnu i programiranju - <?php $ypSiteModules->showTitle(); ?></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="css.css">
<style type="text/css">
</style>
</head>
<body>
<div id="gore"><?php $ypSiteModules->showMainLinks($_GET); ?></div>
<div id="lijevo"><?php $ypSiteModules->showSubLinks($_GET); ?>
<div id="desno"><?php $ypSiteModules->showContent(); ?></div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jednostavno.com - Jednostavno o Web dizajnu i programiranju - <?php $ypSiteModules->showTitle(); ?></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="css.css">
<style type="text/css">
</style>
</head>
<body>
<div id="gore"><?php $ypSiteModules->showMainLinks($_GET); ?></div>
<div id="lijevo"><?php $ypSiteModules->showSubLinks($_GET); ?>
<div id="desno"><?php $ypSiteModules->showContent(); ?></div>
</body>
</html>
showSiteClass.php is this
CODE
<?php error_reporting(E_ALL); ?>
<?php
class c1ShowContent {
private $variable = array ( "index" => array ("PHP Open source sustav" => "opensource"),
"HTML" => array ("Pisanje HTML koda [HTML 0001]" => "pisanjehtmla"),
"PHP" => array ("Instalacija Xampp [PHP 0001]" => "instalacijaxampp" )
);
public function showMainLinks($fun) {
echo "<div class=\"mainLinkovi\"><ul>";
foreach ($this->variable as $key => $val) {
echo "<li><a href=\"?main=".$key."\">$key</a></li>";
}
echo "</ul></div>";
$mainKeys = array_keys ($this->variable);
if (empty($_GET['main'])) {
$this->link = $this->variable["index"];
$this->main = $this->variable = "index";
}
elseif (in_array($_GET['main'], $mainKeys)) {
$this->link = $this->variable[$_GET['main']];
$this->main = $_GET['main'];
}
else {
$this->link = $this->variable["index"];
$this->main = $this->variable = "index";
}
}
public function showSubLinks($fun){
echo "<div class=\"subLinkovi\"><p>Sadržaj - $this->main</p>";
echo "<ul>";
foreach ($this->link as $key => $val) {
echo "<li><a href=\"?main={$this->main}&sub=".$key."\">$key</a></li>";
}
echo "</ul></div>";
$subKeys = array_keys ($this->link);
$this->subKeys =$subKeys;
if (empty($_GET['sub'])){
$this->content = $this->main;
}
elseif (in_array($_GET['sub'], $subKeys)) {
$this->content = $this->link[$_GET['sub']];
}
else {
$this->content = $this->main;
}
}
public function showContent(){
include "stranice/$this->main/$this->content.html";
$filename = "stranice/$this->main/$this->content.html";
if (file_exists($filename)) {
echo "<p class=\"ftime\">Dodano: " . date ("d F Y H:i:s.", filemtime($filename))."</p>";
}
}
public function showTitle() {
$mainKeys = array_keys ($this->variable);
if (empty($_GET['main'])) {
$this->title = "index";
}
elseif (!empty($_GET['main']) && empty($_GET['sub'])) {
if (in_array($_GET['main'], $mainKeys)){
$this->title = $_GET['main'];
}
else {
$this->title = "index";
}
}
elseif (!empty($_GET['sub'])) {
$this->link = $this->variable[$_GET['main']];
$subKeys = array_keys($this->link);
if (in_array($_GET['sub'], $subKeys)){
$this->title = $_GET['sub'];
}
else {
$this->title = "index";
}
}
echo $this->title;
}
}
$ypSiteModules = new c1ShowContent;
?>
<?php
class c1ShowContent {
private $variable = array ( "index" => array ("PHP Open source sustav" => "opensource"),
"HTML" => array ("Pisanje HTML koda [HTML 0001]" => "pisanjehtmla"),
"PHP" => array ("Instalacija Xampp [PHP 0001]" => "instalacijaxampp" )
);
public function showMainLinks($fun) {
echo "<div class=\"mainLinkovi\"><ul>";
foreach ($this->variable as $key => $val) {
echo "<li><a href=\"?main=".$key."\">$key</a></li>";
}
echo "</ul></div>";
$mainKeys = array_keys ($this->variable);
if (empty($_GET['main'])) {
$this->link = $this->variable["index"];
$this->main = $this->variable = "index";
}
elseif (in_array($_GET['main'], $mainKeys)) {
$this->link = $this->variable[$_GET['main']];
$this->main = $_GET['main'];
}
else {
$this->link = $this->variable["index"];
$this->main = $this->variable = "index";
}
}
public function showSubLinks($fun){
echo "<div class=\"subLinkovi\"><p>Sadržaj - $this->main</p>";
echo "<ul>";
foreach ($this->link as $key => $val) {
echo "<li><a href=\"?main={$this->main}&sub=".$key."\">$key</a></li>";
}
echo "</ul></div>";
$subKeys = array_keys ($this->link);
$this->subKeys =$subKeys;
if (empty($_GET['sub'])){
$this->content = $this->main;
}
elseif (in_array($_GET['sub'], $subKeys)) {
$this->content = $this->link[$_GET['sub']];
}
else {
$this->content = $this->main;
}
}
public function showContent(){
include "stranice/$this->main/$this->content.html";
$filename = "stranice/$this->main/$this->content.html";
if (file_exists($filename)) {
echo "<p class=\"ftime\">Dodano: " . date ("d F Y H:i:s.", filemtime($filename))."</p>";
}
}
public function showTitle() {
$mainKeys = array_keys ($this->variable);
if (empty($_GET['main'])) {
$this->title = "index";
}
elseif (!empty($_GET['main']) && empty($_GET['sub'])) {
if (in_array($_GET['main'], $mainKeys)){
$this->title = $_GET['main'];
}
else {
$this->title = "index";
}
}
elseif (!empty($_GET['sub'])) {
$this->link = $this->variable[$_GET['main']];
$subKeys = array_keys($this->link);
if (in_array($_GET['sub'], $subKeys)){
$this->title = $_GET['sub'];
}
else {
$this->title = "index";
}
}
echo $this->title;
}
}
$ypSiteModules = new c1ShowContent;
?>
directory sturcture on root is
-includes
--showSiteClass.php
-stranice
--index
---index.html
---opensource.html
--HTML
---HTML.html
---pisanjehtmla.html
--PHP
---PHP.html
---instalacijaxampp.html
index.php
Problem i found on this class, that it's not dynamic enough. It's fast, and i think it's secure enough, but i got some problems when i wanted to include some pages EG. contact.php, that need another included file eg mailto.php, and can't figure out a way to solve that problem, except by including it in index.php file at start, but than it would be availiable to any file i have, and that's not an option.
I tried to find many good tutorials on writing PHP template system, and am trying to avoid smarty, beacouse i preffer to use my own templating system until i become more familliar with the way it works.
If you had experience in building such a system, please help.
Main problem i think is, array that sets pages, beacouse it's really crude for now, and i need to make it more justifiable (dunno the proper word).
Thanks for any help.

