0
我想创建一个opencart网上商店,其中customerts可以看到内容,如果他们登录,否则重定向到登录页面。我想把它写入代码的地方,没有任何扩展。我在opencart中真的很新。Opencart关闭登录
我想创建一个opencart网上商店,其中customerts可以看到内容,如果他们登录,否则重定向到登录页面。我想把它写入代码的地方,没有任何扩展。我在opencart中真的很新。Opencart关闭登录
请下面的目录/控制器/通用/ header.php文件代码里面添加index()
功能
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'));
}
}
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
}
这实际上会不断重定向,因为标题也用于登录页面 –
@JayGilford答案已更新。它现在应该工作。谢谢 – Samir