外部情報をコンポーネントに追加しようとしていますが、view.html.php
のデータを取得しています。取得したら、モデルでどのように使用できますか?私は思いつく限りの多くの通常の変数を試しましたが、成功しませんでした。 $this
(JModelAdmin
の拡張)の中に埋め込まれているのがわかりますが、その方法を見つけることができます。
example\view.html.php
public function display($tpl = null) {
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
$this->MyInfo = $this->get(MyInfo); // Use $this->item to get my info
models\example.php:
public function getItem($pk = null) {
if (!$item = parent::getItem($pk))
{
throw new Exception('Failed to load item');
}
return $item;
}
public function getMyInfo($pk = null)
{
// Need some of the data from `$this->item` already retrieved in function `display`
// Do some SQL here
return $mydata;
}
Get関数から親を試してください
public function getMyInfo($pk = null)
{
$myItem = parent::getItem($pk);
echo $myItem->myfieldname;
.
.
.