Since it's been a while, I've been reading up on old posts regarding mvc and front/action controllers, and I would now need some comments on how I setup my pages.
Would home.php be considered a controller, with the template acting as a view? I feel confused after not touching either oop or mvc for over a year.
default.php
Code: Select all
<?php
require_once("lib/FrontController.php");
require_once("lib/Locator.php");
$controller = new FrontController();
$locator = new Locator();
$controller = new FrontController($locator,'actions/','home','error','action');
$controller->execute();
?>
Code: Select all
<?php
require_once('../lib/Template.php');
class home
{
public function execute(){
$tpl = new cTemplate('../tpl/base.php');
$tpl->pageTitle = "This is the page title";
$tpl->metatags = array('keywords'=>'php,mysql,apache,etc..','description'=>'a description..');
$tpl->scripts = array('../js/jquery-1.1.3.1.js');
$google = new cTemplate('../tpl/googleAnalytics.php');
$tpl->googleAnalytics = $google->render();
echo $tpl->render();
}
}
?>
Code: Select all
<!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><?php echo $pageTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="content-language" content="en" />
<?php
// Print any supplied meta-tags
if(isset($metatags))
{
foreach($metatags as $metaTag => $metaContent):
?>
<meta name="<?php echo $metaTag; ?>" content="<?php echo $metaContent; ?>" />
<?php
endforeach;
}
?>
<?php
// Print any supplied javascript includes
if(isset($scripts))
{
foreach($scripts as $script):
?>
<script type="text/javascript" src="<?php echo $script; ?>"></script>
<?php
endforeach;
}
?>
</head>
<body>
<?php if(isset($googleAnalytics)) { echo $googleAnalytics; } ?>
</body>
</html>