この質問( コアバックエンドコンポーネントにカスタムボタンを追加 )にあるように、com_contentコンポーネントにカスタムボタンを追加する簡単なプラグインを作成しました。
このボタンをクリックすると、サイトはmy_componentコントローラー、送信タスクにリダイレクトされます。ただし、選択された項目のいずれかがmy_componentコントローラーに送信されます。
選択した記事のIDをコントローラーに渡すにはどうすればよいですか?
これが私のプラグインのソースです:
class plgSystemSubscripcions extends JPlugin {
public function onBeforeRender() {
$app = JFactory::getApplication();
if ($app->isAdmin() === true) {
$input = $app->input;
if (($input->getCmd('option') === 'com_content' && $input->getCmd('view', 'articles') === 'articles') ||
($input->getCmd('option') === 'com_docman' && $input->getCmd('view', 'documents') === 'documents')) {
$toolbar = JToolbar::getInstance('toolbar');
$url = JRoute::_('index.php?option=com_my_component&task=send&format=raw');
$toolbar->appendButton('Link', 'mail', 'Mass email', $url);
}
}
}
}
ボタンはGETアクションのみを呼び出します。つまり、すべての入力フィールドは処理されませんが、選択されたアイテムは入力フィールドです。 この質問 で同じ問題を参照してください。
正直に言うと、それらを渡す方法はわかりません...ボタンがトリックを送信するフォームを送信できる場合は、私が理解しているように、カスタムボタンを使用することはできません。