2012-12-14 89 views
1

我试图在前端显示不同的标题图像基于store id意味着每个商店都有不同的标题图像。在opencart中获取当前商店ID

的问题是如何呼应当前STORE_ID在前端(在header

,所以我可以用我的代码的东西继续象下面这样:

<?php 
if($store_id == '1') { // 1 is default store 
    //echo image here 
} 
else { //if not default show different image 
    //echo image here 
} 
?> 

Opencart的版本:1.4.9.6

+1

[查看此文](http://stackoverflow.com/questions/9916282/get-the-store-id-for-multi-store-setup-with-opencart) – bobthyasian

回答

11

您当前的store_id$this->config->get('config_store_id')

这意味着,如果你需要在模板中,编辑头部控制器(catalog/controller/common/header.php) - 一些在index()函数中添加以下代码(ID它已不存在):

$this->data['store_id'] = $this->config->get('config_store_id'); 

然后在您的header.tpl的您的模板(catalog/view/theme/<YOUR_THEME>/template/common/header.tpl)使用这种方式:

<?php if ($tore_id == 0) { ?> 
<div>Main store</div> 
<?php } else { ?> 
<div>Subdomain store</div> 
<?php } ?> 

或者这样说:

<div class="container-<?php echo $store_id; ?>"> ... </div> 

它在你身上。

编辑:也可以考虑用较新的Opencart的移动上(最新为1.5.4.1 15 2012年12月的) - 它是值得的重新设计和它具有的功能和小工具。

+1

这是值得重新设计的肯定,但考虑大多数1.4.X的用户进行了大量修改(核心编辑)(当时vQmod相对较新),那么升级 –

+0

最有可能成为@JayGilford – rusly