たとえば、thingy フォルダーの下に「stuff」というコントローラーがあり、そのクラス内に「my function」という関数があるとします。これは次のようになります。
class ControllerThingyStuff extends Controller {
public function index() {
// Some code
}
public function myfunction() {
// Your code
}
}
URL を使用してこの関数と直接通信したい場合は、関数名をルート パラメーターの末尾に追加し、"route=thingy/stuff/myfunction& ..." を指定して、thingy.tpl を関数内にロードし、後で返すことができます。レンダリング:
// some code
$this->template = 'template/product/thingy.tpl';
...
$this->response->setOutput($this->render());
オープン カート 1.5 を使用していて、JSON で jQuery AJAX を使用する場合は、レンダリングする前に JSON ライブラリをインポートする必要があります。
$this->template = 'thingy/stuff/thingy.tpl';
$json['output'] = $this->render();
$this->load->library('json');
$this->response->setOutput(Json::encode($json));
いくつかのアイデアを得るためにチェックアウト ページを見てみましょう。デフォルトのオープン カート 1.5 テンプレートは、同じ手法を使用して各セクションのテンプレートを読み込みます。