这就是我用于我的应用程序的内容。看看这是否有帮助:
站点配置.php:
<?php
define('DIR_BASE', dirname( dirname(__FILE__) ));
define('DIR_CLASSES', DIR_BASE . '/classes/');
// this is specific to the site
define('DIR_SITE', DIR_BASE . '/yoursite/');
define('SITE_NAME', 'yoursite');
// these would be specific to this site only
define('DIR_SITE_VIEWS', DIR_SITE . 'views/' );
define('DIR_SITE_COMPONENTS', DIR_SITE . 'components/');
define('BASE_URL', 'http://'.$_SERVER['SERVER_NAME']);
define('SITE_URL', BASE_URL . '/yoursite');
// static content for the site
define('DIR_STATIC', SITE_URL . '/static');
define('DIR_JS', DIR_STATIC . '/js');
define('DIR_CSS', DIR_STATIC . '/css');
define('DIR_SITE_IMG', SITE_URL . '/images');
?>
这是我的模板的样子:
<?php
// site_template.php
// template for adding a new page directly under main directory of this site
require_once('site_config.php');
$pgtitle = "Title of the Page";
include_once(DIR_SITE_VIEWS . 'site_header_begin.php');
// custom css/javascript goes here
include_once(DIR_SITE_VIEWS . 'site_header_end.php');
?>
<?php
// main content of the page goes here
?>
<?php
include_once(DIR_SITE_VIEWS . 'site_footer.php');
?>
site_header_begin.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<?php if (isset($pgtitle) && ($pgtitle != '')){echo $pgtitle." :: ";}?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="AUTHOR" content="" />
<meta name="KEYWORDS" content="" />
<meta name="DESCRIPTION" content="" />
<!-- common css goes here -->
<script type="text/javascript" language="javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.17/jquery-ui.min.js"></script>
site_header_end.php:
</head><!-- end the header here -->
<body ><!-- start the body here -->
site_footer.php:
<div id="footer"><a name="pageFooter"></a>
</div>
</body>
</html>
这将使页眉/页脚“恒定”和动态,并且所有内容都将根据 site_config.php 文件中定义的常量进行定义。您只需要添加适当的视图、静态、类和组件目录。看看这是否有帮助。