ログインしたユーザーのみにサイドバーモジュールを表示する方法はopencartにありますか?
2095 次
2 に答える
1
もちろん簡単な結納もあります!
たとえば、左の列コントローラー ( catalog/controller/common/column_left.php
) を開き、次の行を開きます。
protected function index() {
この条件を追加します (開き括弧のみ):
if($this->customer->isLogged()) {
今すぐ行を見つけます
$this->render();
そして、これを追加する前に:
} else {
$this->data['modules'] = array();
}
したがって、最終的なコードは次のようになります。
<?php
class ControllerCommonColumnLeft extends Controller {
protected function index() {
if($this->customer->isLogged()) {
// ... all the previous code up to the render() call
} else {
$this->data['modules'] = array();
}
$this->render();
}
}
column_right.php
、content_bottom.php
およびで同じことを行います。これcontent_top.php
で完了です ;-)
EDIT :具象モジュールコントローラーを編集してそこに条件を追加することもできますが、これはそれほど単純ではなく、他の意味もあります-利用可能なすべてのモジュールを収集するDBクエリがまだあります. 私のソリューション内では、単純であることに加えて、ログに記録されていないユーザーの場合、モジュールの DB 呼び出しがまったく行われないという事実もあります..
于 2013-10-08T09:45:34.457 に答える