我的商店里有一些制造商,我想修改搜索,以便您可以从下拉菜单中选择制造商 :)
我希望将搜索框更改为 opencart 中的下拉菜单。那可能吗?如果是,请告诉我如何。
谢谢 !
我的商店里有一些制造商,我想修改搜索,以便您可以从下拉菜单中选择制造商 :)
我希望将搜索框更改为 opencart 中的下拉菜单。那可能吗?如果是,请告诉我如何。
谢谢 !
好的,我不知道你为什么要这样做,但这是一种方法......我正在使用标题搜索这个例子,Opencart 1.5.4.1 Edit catalog/controller/commmon/header.php。第 96 行之后:
$this->load->model('catalog/product');
添加这个:
// - - Manufacturers Dropdown Data Start - - - - - - - -
// load manufacturer model
$this->load->model('catalog/manufacturer');
//get manufacturers data
$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
//populate data array for use in view
$this->data['manufacturers'] = array();
foreach ($manufacturers as $manufacturer){
$this->data['manufacturers'][] = array(
'id' => $manufacturer['manufacturer_id'],
'name' => $manufacturer['name']
);
}
// - - Manufacturers Dropdown Data End - - - - - - - - -
现在,在 catalog/view/theme/xxx/template/common/header.tpl 找到搜索 DIV,注释掉搜索输入(第 55-62 行):
<div id="search">
<!-- <div class="button-search"></div>
<?php if ($filter_name) { ?>
<input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
<?php } else { ?>
<input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
<?php } ?> -->
...
添加您的选择元素:
<div id="search">
<!-- <div class="button-search"></div>
<?php if ($filter_name) { ?>
<input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
<?php } else { ?>
<input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
<?php } ?> -->
<select name='manuf_dropdown' ONCHANGE="location = this.options[this.selectedIndex].value;">
<option value=''></option>
<?php foreach ($manufacturers as $manufacturer) {
if (isset($_GET['manufacturer_id']) && $_GET['manufacturer_id'] == $manufacturer['id']){
?>
<option selected="selected" value="./?route=product/manufacturer/info&manufacturer_id=<?php echo $manufacturer['id'] ?>"><?php echo $manufacturer['name'] ?></option>
<?php } else { ?>
<option value="./?route=product/manufacturer/info&manufacturer_id=<?php echo $manufacturer['id'] ?>"><?php echo $manufacturer['name'] ?></option>
<?php }} ?>
</select>
</div>
如果您需要对代码进行任何解释,请告诉我。