我想创建一个opencart网络商店,客户可以看到内容,如果他们登录,否则重定向到登录页面。我想把它写到代码的某个地方,不带任何扩展名。我真的是opencart的新手。
发布于 2015-05-17 20:00:13
请在index()函数内部的catalog/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'));
}
}发布于 2016-04-04 15:34:16
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
}https://stackoverflow.com/questions/30286684
复制相似问题