Cubsonベースのモジュール組み込み型モジュールの作成 (4)
本記事は,d3forum のコメント統合機能のように,他のモジュールに埋め込んで使うモジュールの作成方法を解説するものです。
対象は,Cubson でモジュールを作れて,かつ上のようなモジュールの作り方は分からない方。
今回でラスト。モジュール組み込み型モジュール特有の部分はもうあまり残っていません。
BmImplementAction.class.php
BmImplementAction.class.php を、BmEditAction.class.php をコピーして作ります。クラス名を Bookmark_BmImplementAction に変更して、executeViewInput ファンクションを以下のとおり書き換えます*1。
/** * @public */ function executeViewInput(&$render) { $tpl = new XoopsTpl(); if (!$tpl->is_cached("db:bookmark_bm_implement.html")) { $tpl->assign('actionForm', $this->mActionForm); $tpl->assign('object', $this->mObject); $tpl->display("db:bookmark_bm_implement.html"); } }
bookmark_bm_implement.html
bookmark_bm_edit.html をコピーして作ります。
お好みの表示に合わせて修正していただければ結構ですが、以下の1点は修正が必須です。
<form action="<{$xoops_url}>/modules/bookmark/index.php?action=BmImplement" method="post">
もともとは、action="index.php?action=BmImplement" になっていると思いますが、これだと呼び出し元のモジュールの index.php が呼ばれることになりますので、上記の様に修正します。
以上です。
*1:Cubson のコードのとおり、$render を使ってうまくやる方法もあるのかもしれませんが、僕はこれしか知らない……。