【问题标题】:opencart Adding a custom menu in the header menuopencart 在标题菜单中添加自定义菜单
【发布时间】:2014-07-07 15:42:26
【问题描述】:

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

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

直截了当,但页面是信息页面。

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

advice的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'])
                );      
            }

【问题讨论】:

    标签: php opencart


    【解决方案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');
    


    第三步

    在同一个文件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');
    

    & 然后检查一下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-24
      • 1970-01-01
      • 2012-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2013-04-15
      相关资源
      最近更新 更多