smarty3--registerPlugin()函数报错问题
smarty版本:smarty3.1.30
registerPlugin错误信息:
Notice: Trying to get property of non-object in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
Fatal error: Call to a member function registerPlugin() on null in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
代码示例:
system.smarty.inc.php //smarty模板配置类文件
<?php
require("libs/Smarty.class.php"); //引入smarty类库
class SmartyProject extends Smarty{
function __construct(){ //配置信息
$this->template_dir="./system/templates/";
$this->compile_dir="./system/templates_c/";
$this->config_dir="./system/configs/";
$this->cache_dir="./system/catch/";
}
}
?>
system.inc.php //类的实例化文件
<?php
require("system.smarty.inc.php");
require("system.class.inc.php");
$usefun=new UseFun();
$smarty=new SmartyProject;
function unhtml($params){
extract($params);
$text=$content;
global $usefun;
return $usefun->UnHtml($text);
}
$smarty->registerPlugin('function','unhtml','unhtml'); //注册模板函数
?>
此时会提示错误信息:
Notice: Trying to get property of non-object in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
Fatal error: Call to a member function registerPlugin() on null in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
解决办法:在smarty配置类文件中,引入父类的构造方法。即将system.smarty.inc.php文件改为:
require("libs/Smarty.class.php");
class SmartyProject extends Smarty{
function __construct(){
parent::__construct(); //引入父类的构造方法
$this->template_dir="./system/templates/";
$this->compile_dir="./system/templates_c/";
$this->config_dir="./system/configs/";
$this->cache_dir="./system/catch/";
}
}
此时函数注册成功!
smarty3--registerPlugin()函数报错问题的更多相关文章
- js执行函数报错Cannot set property 'value' of null怎么解决?
js执行函数报错Cannot set property 'value' of null 的解决方案: 原因:dom还没有完全加载 第一步:所以js建议放在body下面执行, 第二步:window.on ...
- python 3 直接使用reload函数报错
reload()是python2 的内置函数可以直接使用,但是python3 直接使用此函数报错,需要导入importlib 模块 from importlib import reload
- Linux 下使用C语言 gets()函数报错
在Linux下,使用 gets(cmd) 函数报错:warning: the 'gets' function is dangerous and should not be used. 解决办法:采用 ...
- C++ socket bind()函数报错 不存在从 "std::_Binder<std::_Unforced, SOCKET &, sockaddr *&, size_t &>" 到 "int" 的适当转换函数
昨天还可以正常运行的程序,怎么今天改了程序的结构就报错了呢?我明明没有改动函数内部啊!!! 内心无数只“草泥马”在奔腾,这可咋办呢?于是乎,小寅开始求助于亲爱的度娘...... 由于小寅知识水平有限, ...
- 光流法draw_flow()函数报错
光流法draw_flow()函数报错 import cv2 from scipy import * def draw_flow(im, flow, step=16): ""&quo ...
- updatexml和extractvalue函数报错注入
updatexml()函数报错注入 updatexml (XML_document, XPath_string, new_value); 第一个参数:XML_document是String格式,为XM ...
- php 升级到 5.3+ 后出现的一些错误,如 ereg(); ereg_replace(); 函数报错
在php5.3环境下运行,常常会出现 Deprecated: Function ereg() is deprecated in...和Deprecated: Function ereg_replace ...
- PHP empty函数报错的解决办法
PHP empty函数在检测一个非变量情况下报错的解决办法. PHP开发时,当你使用empty检查一个函数返回的结果时会报错:Fatal error: Can't use function retur ...
- Linux下编译C代码,出现tan函数报错的情况
undefined reference to `tan' 但是已经包含了头文件 <math.h>了,可还是报错,说是找不到tan 这个问题的原因不是很清楚, 但是网上给出的方案,就是编译的 ...
- geopandas overlay 函数报错问题解决方案
前言 这篇文章依旧是基于上一篇文章(使用Python实现子区域数据分类统计)而写,此文章中介绍了使用 geopandas 的 overlay 函数对两个 GeoDataFrame 对象取相交或相异的部 ...
随机推荐
- 深入理解ob_flush和flush的区别
ob_flush/flush在手册中的描述, 都是刷新输出缓冲区, 并且还需要配套使用, 所以会导致很多人迷惑… 其实, 他们俩的操作对象不同, 有些情况下, flush根本不做什么事情.. ob_* ...
- Android-xUtils框架介绍(四)
今天介绍xUtils的最后一个模块——HttpUtils,拖了那么久,终于要结束了.另外,码字不易,如果大家有什么疑问和见解,欢迎大家留言讨论.HttpUtils是解决日常工作过程中繁杂的上传下载文件 ...
- poj3592Instantaneous Transference(tarjan+spfa)
http://poj.org/problem?id=3592提交了30多次了 受不了了 两份的代码基本上一样了 一个AC一个WA 木办法 贴份别人的吧 改得跟我得一样 人家能A 我是WA.. 强连通 ...
- poj 3083 Children of the Candy Corn(DFS+BFS)
做了1天,总是各种错误,很无语 最后还是参考大神的方法 题目:http://poj.org/problem?id=3083 题意:从s到e找分别按照左侧优先和右侧优先的最短路径,和实际的最短路径 DF ...
- LeeCode Algorithm #3 Longest Substring Without Repeating Characters
一开始以为是不连续的,其实要求子串是连续的.想法:two-pointer O(n)时间,再借助256大小的int数组.两个下标i,j(i<=j).对于i=0,找到最右侧的字符不重复的下标的后一位 ...
- apache开源项目--ApacheDS
ApacheDS (Apache Directory Server)的核心是目录服务,可以保存数据,并对不同类型的数据进行搜索操作.协议的实现在目录服务器顶层工作,提供与数据存储.搜索和检索有关的 I ...
- (1)java虚拟机概念和结构图
java虚拟机解构图一 java虚拟机解构图二 java虚拟机结构图三 [1]类加载系统 --->负责从文件系统或网络中加载class信息,存放至方法区的内存空间[2]java堆 ...
- LINQ之路系列
Life a Poem http://www.cnblogs.com/lifepoem/archive/2011/11/22/2258830.html
- CF GYM 100703I Endeavor for perfection
题意:有n个学习领域,每个领域有m个课程,学习第i个领域的第j个课程可以获得sij个技能点,在每个领域中选择一个课程,要求获得的n个技能点的最大值减最小值最小,输出符合要求的策略. 解法:尺取法.将课 ...
- Android视图SurfaceView的实现原理分析
http://blog.csdn.net/luoshengyang/article/details/8661317