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()函数报错问题的更多相关文章

  1. js执行函数报错Cannot set property 'value' of null怎么解决?

    js执行函数报错Cannot set property 'value' of null 的解决方案: 原因:dom还没有完全加载 第一步:所以js建议放在body下面执行, 第二步:window.on ...

  2. python 3 直接使用reload函数报错

    reload()是python2 的内置函数可以直接使用,但是python3 直接使用此函数报错,需要导入importlib 模块 from importlib import reload

  3. Linux 下使用C语言 gets()函数报错

    在Linux下,使用 gets(cmd) 函数报错:warning: the 'gets' function is dangerous and should not be used. 解决办法:采用 ...

  4. C++ socket bind()函数报错 不存在从 "std::_Binder<std::_Unforced, SOCKET &, sockaddr *&, size_t &>" 到 "int" 的适当转换函数

    昨天还可以正常运行的程序,怎么今天改了程序的结构就报错了呢?我明明没有改动函数内部啊!!! 内心无数只“草泥马”在奔腾,这可咋办呢?于是乎,小寅开始求助于亲爱的度娘...... 由于小寅知识水平有限, ...

  5. 光流法draw_flow()函数报错

    光流法draw_flow()函数报错 import cv2 from scipy import * def draw_flow(im, flow, step=16): ""&quo ...

  6. updatexml和extractvalue函数报错注入

    updatexml()函数报错注入 updatexml (XML_document, XPath_string, new_value); 第一个参数:XML_document是String格式,为XM ...

  7. php 升级到 5.3+ 后出现的一些错误,如 ereg(); ereg_replace(); 函数报错

    在php5.3环境下运行,常常会出现 Deprecated: Function ereg() is deprecated in...和Deprecated: Function ereg_replace ...

  8. PHP empty函数报错的解决办法

    PHP empty函数在检测一个非变量情况下报错的解决办法. PHP开发时,当你使用empty检查一个函数返回的结果时会报错:Fatal error: Can't use function retur ...

  9. Linux下编译C代码,出现tan函数报错的情况

    undefined reference to `tan' 但是已经包含了头文件 <math.h>了,可还是报错,说是找不到tan 这个问题的原因不是很清楚, 但是网上给出的方案,就是编译的 ...

  10. geopandas overlay 函数报错问题解决方案

    前言 这篇文章依旧是基于上一篇文章(使用Python实现子区域数据分类统计)而写,此文章中介绍了使用 geopandas 的 overlay 函数对两个 GeoDataFrame 对象取相交或相异的部 ...

随机推荐

  1. Android中Input型输入设备驱动原理分析<一>

    话说Android中Event输入设备驱动原理分析还不如说Linux输入子系统呢,反正这个是没变的,在android的底层开发中对于Linux的基本驱动程序设计还是没变的,当然Android底层机制也 ...

  2. chrome渲染hover状态tranform相邻元素抖动bug

    最近同事在使用 css3 的 transition + tranform 的时候影响了相邻的元素出现bug.或者说相邻的元素出现抖动bug. 然而把 hover 状态的 tranform 属性删了后, ...

  3. hdu4614Vases and Flowers

    http://acm.hdu.edu.cn/showproblem.php?pid=4614 线段树的各种操作 写的有点乱 求插入位置是以区间K值的方法求出的 向下更新 #include <io ...

  4. POJ2528 线段树的区间操作

    首先应该对该[0,10000000]进行离散化 即先将点集进行排序,然后从小到大缩小其中的间距,使得最后点数不会超过2*n 然后就是线段树操作 只需进行染色,然后最后用nlgn进行一个个查询颜色记录即 ...

  5. mysql 共享锁-排它锁

    转  InnoDB 行级锁 http://www.cnblogs.com/dongqingswt/archive/2013/03/28/2987367.html InnoDB 行级锁 分类: 数据库2 ...

  6. Sencha touch navigation 内嵌list,itemTap第二次点击不跳转的问题

    情景:navigation view 内嵌list,第一次触发list事件itemtap,正常跳转至详情页,点击"defaultBackButton"返回至list正常;再次点击触 ...

  7. Building QT projects from the command line

    /************************************************************************ * Building QT projects fro ...

  8. (四)学习JavaScript之className属性

    参考:http://www.w3school.com.cn/jsref/prop_classname.asp HTML DOM Anchor 对象 定义和用法 className 属性设置或返回元素的 ...

  9. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.5

    Show that the inner product $$\bex \sef{x_1\vee \cdots \vee x_k,y_1\vee \cdots\vee y_k} \eex$$ is eq ...

  10. [转]ubuntu zip 文件乱码解决 压缩乱码

    ubuntu zip 文件乱码解决 压缩乱码 1.1 通过unzip行命令解压,指定字符集 unzip -O CP936 xxx.zip (用GBK, GB18030也可以) 有趣的是unzip的ma ...