我使用的是Opencart 1.5.4.1版,我已经安装了商店模块&下拉列表中有3个商店(例如默认值,Store1,Store2)。
我的要求是将最后一个商店(示例Store2)重定向到account/login
。
我尝试将\catalog\controller\module\store.php
中的路径从index.php?route=common/home
修改为index.php?route=account/login
,但Store1和& Store2被重定向到account/login
。
我还尝试使用以下if
条件:如果我从默认选择Store1& Store1到Store2,它正常工作,但是如果从默认选择Store2,它就无法正常工作。
foreach ($results as $result) {
if((int)$this->config->get('config_store_id')==1)
{
$this->data['stores'][] = array(
'store_id' => $result['store_id'],
'name' => $result['name'],
'url' => $result['url'] . 'index.php?route=account/login'
);
}
else
{
$this->data['stores'][] = array(
'store_id' => $result['store_id'],
'name' => $result['name'],
'url' => $result['url'] . 'index.php?route=common/home'
);
}
}
答案 0 :(得分:0)
您可以使用以下vqmod code
:
.xml
的文件。vqmod\xml
文件夹。<modification>
<id>Force Customer Login</id>
<version>152.1</version>
<vqmver>2.1.5</vqmver>
<author>Qphoria</author>
<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;
}
}
}
if (!$match) {
if (!$this - > customer - > isLogged()) {
if ($this - > config - > get('config_store_id') == 1) {
$this - > redirect($this - > url - > link('account/login', 'SSL'));
}
}
}
]]>
</add>
</operation>
</file>
</modification>