Tys*_*sen 1 plugins expressionengine
我正在尝试将外部库加载到ExpressionEngine插件中,但我得到:
消息:未定义属性:Detector :: $ EE
在插件本身我有:
public function __construct()
{
$this->EE->load->library('detector');
$this->EE =& get_instance();
}
Run Code Online (Sandbox Code Playgroud)
我的文件夹设置如下:
检测器
-libraries
--Detector.php
-pi.detector.php
我究竟做错了什么?
移过加载库错误后,我现在使用以下代码收到"未定义变量"错误:
public function detector()
{
return $ua->ua;
}
public function user_agent()
{
return $ua->ua;
}
Run Code Online (Sandbox Code Playgroud)
如果我的模板中有{exp:detector:user_agent},那就是这样.如果我{exp:detector}我没有输出.
小智 7
你应该改变你的代码:
$this->EE =& get_instance();
$this->EE->load->add_package_path(PATH_THIRD.'/detector');
$this->EE->load->library('detector');
Run Code Online (Sandbox Code Playgroud)
首先初始化$this->EE变量,然后可以加载库.所以在这种情况下它会
$this->EE->detector->user_agent();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1271 次 |
| 最近记录: |