php Smarty模版引擎中引入javascript源文件
来源:互联网 发布:r语言爬虫 知乎 编辑:程序博客网 时间:2024/05/17 22:30
采用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 = '<{';
self::$smart_tpl->right_delimiter = '}>';
}
return self::$smart_tpl;
}
require_once('./php/include/common.php');
require_once(WEB_PHP . '/starton.php');
$tpl = app::get_tpl();
$tpl->assign('meta_keywords',APP_KEYWORDS);
$tpl->assign('meta_author',APP_AUTHOR);
$tpl->assign('meta_desc',APP_DESC);
$tpl->assign('web_templetdir',WEB_Tpl_Path);
$tpl->assign('title',APP_TITLE);
$tpl->assign('web_code',WEB_CODE);
$tpl->display('index.html');
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<{$web_code}>">
<meta name="keywords" content="<{$meta_keywords}>">
<meta name="author" content="<{$meta_author}>">
<meta name="description" content="<{$meta_desc}>">
<title><{$title}></title>
<link href="./css/index.css" rel="stylesheet" type="text/css" />
<script src="<{$web_templates}>/js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
alert('ok');
$("p").css("color","red");
});
</script>
</head>
<body>
<p>ssss</p>
</body>
</html>
发现jquery.js没有引入成功。经过一点一点测试发现web_templates是路径c:/php/..../jquery.js 无效。
必须是url的方式如
http://localhost:6060/chshsl/templets/js/jquery.js
- php Smarty模版引擎中引入javascript源文件
- PHP 模版引擎Smarty介绍
- php中smarty模版引擎中的缓存应用!
- php smarty模版引擎中变量操作符及使用方法
- php中smarty模版引擎中常用的20个变量操作符及使用方法!
- Smarty模版引擎
- 模版引擎smarty
- 什么是smarty模版引擎
- 在Zend Framework 应用中使用Smarty做模版引擎
- PHP Smarty模版基础知识
- PHP中Smarty引擎的常用语法
- PHP 中使用 Smarty 之初:认识 Smarty 模板引擎
- PHP模板引擎Smarty
- [php] smarty模板引擎
- PHP模板引擎(Smarty)
- PHP模板引擎(smarty)
- 关于php smarty模版入门
- ZParse javascript模版引擎
- 线段树Hotel
- linux 线程
- java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)
- 学习过程中遇到的Exception
- Column Name Precedence
- php Smarty模版引擎中引入javascript源文件
- 黑马程序员—C#访问修饰符 public、private、protected 和 internal
- 关于领导与员工相处的一个例子
- occi获取表,列,类型
- 中国地图偏移问题
- IOS开发网络加载图片缓存策略之──ASIDownloadCache缓存策略
- v校:关于白名单文件劫持与和谐启动的那些事儿~
- N的阶乘递归算法
- vijos1071【动态规划】