在标题菜单中添加自定义菜单


opencart Adding a custom menu in the header menu

这是我遇到的一个棘手的问题

我有一个客户/朋友,希望在他们的开放购物车菜单上有一个home按钮,我能够解决。然而,他想要一个包含5个项目的下拉菜单。这五项分别是常见问题联系我们送货详情隐私政策退货政策

这些页面都是信息页面。

我想做的是链接到这些页面。

告警ID为80

            foreach ($children as $child) {
                if ($child['category_id'] == 80) {
                    $children_data[] = array(
                        'name' => $this->data['text_advicefaq'] = $this->language->get('text_advicefaq'),
                        'href' => $this->url->link('information/information', 'information_id=13')
                    );
                }
                $data = array(
                    'filter_category_id'  => $child['category_id'],
                    'filter_sub_category' => true
                );
                $product_total = $this->model_catalog_product->getTotalProducts($data);
                $children_data[] = array(
                    'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
                    'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
                );      
            }

试试

步骤1

打开catalog/view/theme/<your theme>/template/common/header.tpl文件

查找菜单代码

前添加</ul>标签:

      <li><a><?php echo $text_information; ?></a>
        <div>
          <ul>
            <?php foreach ($informations as $information) { ?>
            <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
            <?php } ?>
          <li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
          </ul>
        </div>
      </li>


<标题> 第2步

打开文件catalog/controller/common/header.php .

:

$this->data['text_checkout'] = $this->language->get('text_checkout');

之后添加:

$this->data['text_information'] = $this->language->get('text_information');
$this->data['text_contact'] = $this->language->get('text_contact');


<标题>步骤3

在同一文件catalog/controller/common/header.php

:

    $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');

之后添加:

    $this->load->model('catalog/information');
    $this->data['informations'] = array();
    foreach ($this->model_catalog_information->getInformations() as $result) {
        if ($result['bottom']) {
            $this->data['informations'][] = array(
                'title' => $result['title'],
                'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
            );
        }
    }
    $this->data['contact'] = $this->url->link('information/contact');

,