[PHP]Template engine question [$_GET stuff]

Status
Not open for further replies.

Adil

DevBest CEO
May 28, 2011
1,276
714
Hello. I've recently been working on a minimal php framework/web system and I have this basic function:
PHP:
<?php
 
public function handleCall()
{
if(isset($_GET['p']))
{
switch($_GET['p'])
{
case 'about':
$tpl->AddTPL('about');
break;
 
 
case 'contact':
$tpl->AddTPL('contact');
break;
 
}
}
}
 
?>

That is my handler for different urls, so instead of making a page for each template page (e.g you have foo.html in your views folder, and then you must have foo.php in your root folder), it uses a single page with some url rewriting.

My question is, would it be better to use:
PHP:
include('mypage.html');
//instead of
$tpl->AddTPL('mypage');

Using my current system ($tpl->AddTPL()), I can include the file but it also includes my original index page. E.g, if I have "adil" on my index page, and "blah" on my register page, when I navigate to index.php?p=register, it will have "adil blah".

If I were to use $tpl->AddTPL(), how would I go about "deleting" the index content and only throwing out the requested page content?

Help would be greatly appreciated :D
-Adil
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Make the index a requested page content.

Also,
PHP:
<?php 
 
public function handleCall() 
{ 
    if(isset($_GET['p'])) 
    { 
        $tpl->AddTPL($_GET['p']); 
    } 
} 
 
?>
 
Status
Not open for further replies.

Users who are viewing this thread

Top