Php 将活动类添加到制造商&;信息模块OpenCart
我正在尝试添加一个Php 将活动类添加到制造商&;信息模块OpenCart,php,opencart,Php,Opencart,我正在尝试添加一个活动的类,以便将其样式设置为制造商和信息模块。我在左栏中展示了这两个项目,就像常规类别一样。 但是我在添加活动类时遇到了问题 我试图从category.tpl中克隆代码,以便在中添加这样的活动类 catalog/view/theme/default/template/module/manufacturer.tpl <div class="box"> <div class="box-heading"><span><?php ec
活动的
类,以便将其样式设置为制造商和信息模块。我在左栏中展示了这两个项目,就像常规类别一样。
但是我在添加活动类时遇到了问题
我试图从category.tpl
中克隆代码,以便在中添加这样的活动类
catalog/view/theme/default/template/module/manufacturer.tpl
<div class="box">
<div class="box-heading"><span><?php echo $heading_title; ?></span></div>
<div class="box-content">
<ul class="box-category">
<?php foreach ($manufacturers as $manufacturer) { ?>
<li>
<?php if ($manufacturer['manufacturer_id'] == $manufacturer_id) { ?>
<a href="<?php echo $manufacturer['href']; ?>" class="active"><?php echo $manufacturer['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $manufacturer['href']; ?>"><?php echo $manufacturer['name']; ?></a>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
</div>
-
但它不起作用,有人能帮我吗
OpenCart 1.5.6在您的模块中,我相信您有一个
$\u GET['manufacturer\u id']
参数,因此您需要将其设置为
if($this->request->get['manufacturer_id']) {
$this->data['manufacturer_id'] = $this->request->get['manufacturer_id'];
} else {
$this->data['manufacturer_id'] = 0;
}
这将使用URL的查询字符串部分中的
制造商id
,如果存在,或者如果不存在,则将其设置为0
。控制器中是否设置了变量$manufacturer\u id
?在控制器中,您应该有如下内容:$this->data['manufacturer\u id']=$this->request->get['manufacturer\u id']代码>.hm我得到了$此->数据['manufacturer_id']=$parts[0];}else{$this->data['manufacturer\u id']=0;但是$parts[0]
在分类中使用,在URL中有path
参数。在您的模块中,我相信您有一个$\u GET['manufacturer\u id']
参数,因此您需要将其设置为$this->data['manufacturer\u id'=$this->request->GET['manufacturer\u id']
.Ah很好,更近了一步,非常感谢,这解决了问题,但只有在浏览制造商时,当在同一页面上有类别菜单,并且浏览其中一个时,我才得到一个未定义的索引:控制器文件上更改行的制造商id当然,需要设置}否则{$this->data['manufacturer\u id']=0,非常感谢!更新:这解决了制造商模块,但信息模块仅在SEO关闭时工作,因此index.php?route=information/information&information_id=1从information.tpl中提供了一个活动类,但当SEO打开时,它什么也不提供。这是否应该作为一个新问题提出?这很奇怪,因为e URLhttp://my.opencart.com/about-us-information/
最终应该重写为http://my.opencart.com/index.php?route=information/information&information_id=1
所以如果你做了echo$this->request->get['information\u id']
在控制器中,它应该打印出1
。如果不是,你的url有问题。\u重写…是的,打印出1,所以重写看起来很好,可能是信息有问题。那么tpl?我有