<?php 
 
require_once("../../x64Template.php"); 
 
$tpl=new x64Template(false); 
 
require_once("config.php"); 
 
// 
//We get the name of the page... 
// 
$_GET['page']=(array_key_exists('page',$HTTP_GET_VARS))? $HTTP_GET_VARS['page'] : 'home'; 
 
// 
//If the page doesn't exists in the structure then we set an empty value an we die 
// 
if(!array_key_exists($_GET['page'],$structure)) 
{ 
    $tpl->set('content','',true); 
    die($tpl->fetch("template/main.tpl")); 
} 
 
// 
//Now the file that corresponds to that page 
// 
$page_file=$structure[$_GET['page']]; 
 
// 
//Now we get the content of the page 
// 
$page_contents=file_get_contents($page_file); 
 
$tag=array(); 
// 
//Now we extract some tags from the page file 
//Note: I repeat the code for each time so you understand that x64Template::get_statement() doesn't remove anything, it just takes a piece of text from $page_contents 
// 
$tags=$tpl->get_tags('title','page'); 
$tag['title']=x64Template::get_statement($tags,$page_contents); 
$page_contents=str_replace($tags['b'].$tag['title'].$tags['e'],'',$page_contents); 
$tag['title']=html_entity_decode($tag['title']); 
//... 
$tags=$tpl->get_tags('keywords','page'); 
$tag['keywords']=x64Template::get_statement($tags,$page_contents); 
$page_contents=str_replace($tags['b'].$tag['keywords'].$tags['e'],'',$page_contents); 
$tag['keywords']=html_entity_decode($tag['keywords']); 
//... 
$tags=$tpl->get_tags('author','page'); 
$tag['author']=x64Template::get_statement($tags,$page_contents); 
$page_contents=str_replace($tags['b'].$tag['author'].$tags['e'],'',$page_contents); 
$tag['author']=html_entity_decode($tag['author']); 
//... 
$tags=$tpl->get_tags('description','page'); 
$tag['description']=x64Template::get_statement($tags,$page_contents); 
$page_contents=str_replace($tags['b'].$tag['description'].$tags['e'],'',$page_contents); 
$tag['description']=html_entity_decode($tag['description']); 
//... 
$tags=$tpl->get_tags('robots','page'); 
$tag['robots']=x64Template::get_statement($tags,$page_contents); 
$page_contents=str_replace($tags['b'].$tag['robots'].$tags['e'],'',$page_contents); 
$tag['robots']=html_entity_decode($tag['robots']); 
 
// 
//Now we set the tags 
// 
foreach ($tag as $tag_name=>$tag_value) 
{ 
    $tpl->set($tag_name,$tag_value); 
} 
// 
//We parse the page and we set the content to the tag:content 
// 
$tpl->set('content',$tpl->parse($page_contents),true); 
 
// 
//And finally we parse the main template and we die 
// 
die($tpl->fetch("template/main.tpl")); 
?>
 
 |