リストの内容をExcelにエクスポートするカスタムJToolbar
ボタンをリストビューに追加しようとしています。リストコントローラーに新しいタスクを作成して、rawビュークラスをview.raw.phpというファイルにレンダリングしました。ただし、生データのみをロードするコンテンツを取得できません。
関連するコントローラーコードをcom_bannerstracks.raw.phpコントローラーからコピーしました
コントローラー方式:
_public function exportToExcel()
{
// Get the document object.
$document = JFactory::getDocument();
$vName = 'Mylist';
$vFormat = 'raw';
// Get and render the view.
if ($view = $this->getView($vName, $vFormat))
{
// Get the model for the view.
$model = $this->getModel($vName);
// Push the model into the view (as default).
$view->setModel($model, true);
// Push document object into the view.
$view->document = $document;
$view->display();
}
}
_
そして、私のview.raw.phpファイルの簡単なテスト表示メソッド:
_public function display($tpl = null)
{
echo "Test";
}
_
これは「テスト」を表示しますが、テンプレートもロードします。
私は$document->setType('Raw')
を使ってみましたが、これは私に
レンダラークラスをロードできません
エラー。
これの理由はそれが探しているということです
libraries/joomla/document/raw/renderer/modules.php
存在しません。
たぶん私はこれを間違った方法で行っていますが、これをどのように正しく行う必要がありますか?
format=raw
を使用して、URL呼び出しでドキュメントタイプを指定する必要があります。 Joomlaは自動的にview.raw.php
ファイルをロードします。そのための特別なコントローラーも必要ありません。
ツールバーボタンを作成するには、これを使用できます:
$bar = JToolBar::getInstance('toolbar');
$bar->appendButton('Custom', '<button onclick="window.location.href = \'http://www.google.com\';">Export</button>', 'export');