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. Linux信号列表

    我们运行如下命令,可看到Linux支持的信号列表: ~$ kill -l1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL5) SIGTRAP 6) SIGABRT 7) ...

  2. 睡眠--TASK_INTERRUPTIBLE and TASK_UNINTERRUPTIBLE

    http://i.cnblogs.com/EditPosts.aspx?opt=1   Two states are associated with sleeping, TASK_INTERRUPTI ...

  3. netty 实现socket服务端编写

    import java.net.InetSocketAddress; import io.netty.bootstrap.ServerBootstrap; import io.netty.channe ...

  4. IL指令集(转)

    名称 说明 Add 将两个值相加并将结果推送到计算堆栈上. Add.Ovf 将两个整数相加,执行溢出检查,并且将结果推送到计算堆栈上. Add.Ovf.Un 将两个无符号整数值相加,执行溢出检查,并且 ...

  5. poj 1836 Alignment(dp)

    题目:http://poj.org/problem?id=1836 题意:最长上升子序列问题, 站队,求踢出最少的人数后,使得队列里的人都能看到 左边的无穷远处 或者 右边的无穷远处. 代码O(n^2 ...

  6. 逆序对的相关问题:bzoj1831,bzoj2431

    先从简单一点的bzoj2431入手: n个数1~n已经限定了,所以 对于1~i-1,新加入i,最多可以增加i-1个逆序对,最少增加0个逆序对 f[i,j]表示1~i形成的序列逆序对为j的方案数 比较容 ...

  7. [原]Unity3D深入浅出 - 认识开发环境中的Project面板

      前面几个是用来创建脚步的,从Prefab说起: Prefab:预设物体,若一个Object在Scene中多处用到,即可选择为改对象创建一个Prefab.创建一个Prefab后,将源Object拖拽 ...

  8. POJ 1149 PIGS ★(经典网络流构图)

    [题意] 有M个猪圈,每个猪圈里初始时有若干头猪.一开始所有猪圈都是关闭的.依 次来了N个顾客,每个顾客分别会打开指定的几个猪圈,从中买若干头猪.每 个顾客分别都有他能够买的数量的上限.每个顾客走后, ...

  9. postInvalidate、removeAllViewsInLayout、refreshDrawableState用法

    postInvalidate.invalidate:会调用控件的onDraw()重绘控件 refreshDrawableState:当控件在使用一个对控件状态敏感的Drawable对象时使用,如一个B ...

  10. Beginning Android 4 Programming Book学习

    Chapter 3 EditText不自动获取焦点,自动获取焦点但不显示软键盘  Page 122-123 只有定义了android:id属性的控件在屏幕翻转后状态才会被持久化  Page 133 C ...