opencart中是否有任何方法只为登录用户显示侧栏模块?
答案 0 :(得分: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
中执行相同操作,您应该完成; - )
编辑:有人可能还想编辑具体的模块控制器并在那里添加条件,但这不会那么简单并且有其他含义 - 仍然会有数据库查询收集所有可用的模块。在我的解决方案中,除了它的简单性之外,还有一个事实是,对于 unlogged 用户,根本不会对模块进行DB调用。
答案 1 :(得分:1)
感谢您的快速回复。我找到了一个简单的解决方案。
转到我的模块控制器
用$this->render();
if(!$this->customer->isLogged()) { $this->render(); }
它运作良好。