作者:骑马的仓鼠 | 来源:互联网 | 2023-09-13 14:30
采用XAPM开发Php的网站,使用了Smarty模版引擎。源码如下:define(WEB_INCLUDE,str_replace(\\,,dirname(__FILE__))
采用XAPM开发Php的网站,使用了Smarty模版引擎。
源码如下:
define('WEB_INCLUDE',str_replace("\\", '/', dirname(__FILE__)));
define('WEB_PHP', dirname(WEB_INCLUDE));
define('WEB_CLASS',WEB_PHP . '/class');
define('WEB_DIR', dirname(WEB_PHP));
define('WEB_Tpl_Engine', WEB_PHP . '/smarty');
define('WEB_Tpl_Path', WEB_DIR . '/templets');
define('WEB_Tpl_Cache_Time', 0);
public static function get_tpl()
{
if(null === self::$smart_tpl){
require_once(WEB_Tpl_Engine . '/Smarty.class.php');
self::$smart_tpl = new Smarty();
self::$smart_tpl->template_dir = WEB_Tpl_Path;
self::$smart_tpl->compile_dir = WEB_Tpl_Engine . '/template_c';
self::$smart_tpl->config_dir = WEB_Tpl_Engine . '/configs';
self::$smart_tpl->cache_dir = WEB_Tpl_Engine . '/cache';
if(WEB_Tpl_Cache_Time > 0){
self::$smart_tpl->caching = true;
self::$smart_tpl->cache_lifetime = WEB_Tpl_Cache_Time;
}else{
self::$smart_tpl->caching = false;
self::$smart_tpl->cache_lifetime = 0;
}
self::$smart_tpl->left_delimiter &#61; &#39;<{&#39;;
self::$smart_tpl->right_delimiter &#61; &#39;}>&#39;;
}
return self::$smart_tpl;
}
require_once(&#39;./php/include/common.php&#39;);
require_once(WEB_PHP . &#39;/starton.php&#39;);
$tpl &#61; app::get_tpl();
$tpl->assign(&#39;meta_keywords&#39;,APP_KEYWORDS);
$tpl->assign(&#39;meta_author&#39;,APP_AUTHOR);
$tpl->assign(&#39;meta_desc&#39;,APP_DESC);
$tpl->assign(&#39;web_templetdir&#39;,WEB_Tpl_Path);
$tpl->assign(&#39;title&#39;,APP_TITLE);
$tpl->assign(&#39;web_code&#39;,WEB_CODE);
$tpl->display(&#39;index.html&#39;);
">
">
">
">
ssss
发现jquery.js没有引入成功。经过一点一点测试发现web_templates是路径c:/php/..../jquery.js 无效。
必须是url的方式如
http://localhost:6060/chshsl/templets/js/jquery.js