继这个问题之后,我现在正在尝试重新设计插件,以便我可以做到:
{exp:deetector}
{user_agent}
{hash}
{/exp:deetector}
但是使用下面的代码,我没有得到任何输出:
public function __construct()
{
$this->EE =& get_instance();
include(PATH_THIRD.'/deetector/libraries/detector.php');
$this->ua = $ua;
$tagdata = $this->EE->TMPL->tagdata;
$variables[] = array(
'user_agent' => $this->ua->ua,
'hash' => $this->ua->uaHash,
'browser_os' => $this->ua->full,
'browser' => $this->ua->browser,
'browser_full' => $this->ua->browserFull
);
return $this->EE->TMPL->parse_variables($tagdata, $variables);
}
如果我$this->return_data = $this->ua->xx
对上面列出的每个变量都执行此操作,我会得到输出,但如果我解析 $variables 数组则不会。
我也试过$variables = array
但得到Undefined offset: 0。