私は外部ライブラリに基づいてデバイス検出を行うプラグインに取り組んでいます。
これは私がこれまでに持っているものです:
class Deetector {
// public $return_data;
/**
* Constructor
*/
public function __construct()
{
$this->EE =& get_instance();
$this->EE->load->add_package_path(PATH_THIRD.'/deetector');
$this->EE->load->library('detector');
$this->return_data = "";
}
public function deetector()
{
return $ua->ua;
}
public function user_agent()
{
return $ua->ua;
}
// ----------------------------------------------------------------
/**
* Plugin Usage
*/
public static function usage()
{
ob_start();
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
}
{exp:deetector}を呼び出すと、テンプレートに出力がありません。{exp:deetector:user_agent}を呼び出すと、未定義の変数uaが返されます。
最終的には、Detectorライブラリが返す変数ごとに異なる関数を設定する予定はありませんが、現時点では、何かを出力するようにしようとしています。
私はもともと、Detectorライブラリの変数をグローバル変数配列に追加する拡張機能としてこれを開始しましたが、これは正常に機能していました。私が問題にぶつかったのは、プラグインとしてそれをやろうとしてからです。