目前,当我转到https://domain.com时,我可以看到完整的首页,只有当我点击某个项目时,才会转到登录页面。我希望在输入https://domain.com后立即转到登录页面,以便未注册的用户无法在首页上看到产品和价格。
目前,将 vQmod 与名为 force_customer_login.xml 的xml文件一起使用,如下所示:
<modification>
<file name="catalog/controller/common/header.php">
<operation>
<search position="after"><![CDATA[
function index()
]]></search>
<add trim="true"><![CDATA[
//Q: Force Customer Login
$match = false;
if (!empty($this->request->get['route'])) {
$skip = array(
'payment',
'feed',
'forgotten',
'login',
'register',
);
foreach ($skip as $s) {
if (strpos($this->request->get['route'], $s) !== false) {
$match = true;
break;
}
}
}
$dest_route = 'account/login';
if (!$match) {
if (!$this->customer->isLogged() && ($_SERVER['QUERY_STRING'] != "" && $_SERVER['QUERY_STRING'] != 'route=' . $dest_route)) {
$this->response->redirect($this->url->link($dest_route, '', 'SSL'));
}
}
]]></add>
</operation>
</file>
</modification>
我的上述要求。我应该做什么修改。我是opencart和vQmod的新手。提前感谢。
答案 0 :(得分:0)
//@route get the the current page
$route = $this->request->get['route'];
//check if customer is logged in else redirect to login
if (!$this->customer->isLogged() && $route !='account/login' && $route !='account/forgotten' && $route !='account/register') {
$this->response->redirect($this->url->link('account/login', '', true));
}