1

ログインしたユーザーのみにサイドバーモジュールを表示する方法はopencartにありますか?

4

2 に答える 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.phpcontent_bottom.phpおよびで同じことを行います。これcontent_top.phpで完了です ;-)

EDIT :具象モジュールコントローラーを編集してそこに条件を追加することもできますが、これはそれほど単純ではなく、他の意味もあります-利用可能なすべてのモジュールを収集するDBクエリがまだあります. 私のソリューション内では、単純であることに加えて、ログに記録されていないユーザーの場合、モジュールの DB 呼び出しがまったく行われないという事実もあります..

于 2013-10-08T09:45:34.457 に答える