Opencart关闭登录

时间:2015-05-17 11:53:22

标签: php opencart

我想创建一个opencart网上商店,客户可以在登录后查看内容,否则会重定向到登录页面。我想将它写入代码中的某个地方,没有任何扩展名。我在opencart中真的很新。

2 个答案:

答案 0 :(得分:1)

请在index()功能

中的目录/ controller / common / header.php上添加以下代码
 if (!$this->customer->isLogged()) {
       if (!isset($this->request->get['route']) || $this->request->get['route'] != 'account/login') {  

           $this->redirect($this->url->link('account/login', '', 'SSL'));
       }
    }

如果要同时启用注册和登录,请执行以下操作:

if (!$this->customer->isLogged()) {
       if (!isset($this->request->get['route']) || ($this->request->get['route'] != 'account/login' && $this->request->get['route'] != 'account/register')) {  

           $this->redirect($this->url->link('account/login', '', 'SSL'));
       }
    }

答案 1 :(得分:0)

You need add below code

    if (!$this->customer->isLogged()) { //content code here
    }else{ $data['content']=''}

add above code on controller and enclose content so that only login user will be able to see that content.
and add link "login to view content" and use anchor tag to 
login page 
if($content=''){
//redirect code
}