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 对象取相交或相异的部 ...
随机推荐
- 函数buf_LRU_get_free_block
/******************************************************************//** Returns a free block from th ...
- 扫描.net dll引用dll
最近升级系统里的NHibernate,从3.3到4,项目工程太多, 一个模块分bll,dal,model,web,test,10几个模块,就要60多dll,升级一次太头疼. 编译过后,有时候会有的dl ...
- bzoj2456
有趣的题目 空间1mb,所以开数组的算法就不要想了(我一开始没看到……) 仔细读题,然后发现这里他限定众数为出现超过n div 2次 也就是说,这个数可以对应每一个不相同的数消掉,最终还剩下这个数 也 ...
- vfp 操作excel
VFP全面控制EXCEL 收藏 VFP和Excel都可以用来进行处理数据库表格,如果巧妙地将二者的优点结合起来,将会大大方便我们的工作.比如我们可以利用VFP进行处理数据,而利用Excel的预览打印功 ...
- SHA-1加密
/** * SHA-1加密 * @param strSrc 要加密的字符串 * @return 加密后的字符串 */ public static String SHAEncrypt(String st ...
- 【转】android开发工具Eclipse,androidStudio,adt网盘下载--不错
原文网址:http://tools.android-studio.org/index.php/85-tools/109-android-tools-download
- 【转】AngularJS路由和模板
1. AngularJS路由介绍 AngularJS路由功能是一个纯前端的解决方案,与我们熟悉的后台路由不太一样.后台路由,通过不同的URL会路由到不同的控制器上(controller),再渲染(re ...
- C#第三方控件的使用
一.DEVEXPRESS的使用 官网:https://www.devexpress.com/ 入门教程:http://wenku.baidu.com/link?url=2sXEEby1ffx9JTWG ...
- ChineseCounter.cs 统计中文文本中常用字占比
http://www.tuicool.com/articles/qmMba2 1 using System; using System.IO; using System.Collections.Gen ...
- 浏览器插件 - 通用注入模版JS
//TIP:先通过Tampermonkey编写为可用脚本,再套用此通用模版,再拖到Chrome安装为扩展即可. /* 通用注入原型3:*/ switch (window.location.pathna ...