opencart 1.5如何在标题中添加模块 [英] opencart 1.5 how to add module in a header

查看:97
本文介绍了opencart 1.5如何在标题中添加模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我如何在标题中放置滑块或横幅之类的模块,或者如何为模块定义其他区域.

Please some one tell me how can I position modules like slider or banner in header or how can we define additional regions for the modules.

推荐答案

好吧,我正在努力.

首先,您应该在管理页面中添加新职位. 这意味着您应该更改三个文件,并在每个文件中添加一些行.

Firstly, you should add a new position in the admin page. Which means you should change three files and add some lines into each.

例如,如果要将幻灯片放到标题中,则应在

For example, if you want to add slideshow into header, you should add a new position in

$this->data['text_header'] = $this->language->get('text_header'); // in admin/controller/slideshow.php

//////////////////////////////////////////////////

////////////////////////////////////////////////

$_['text_header']         = 'Header'; // in admin/language/slideshow.php

//////////////////////////////////////////////////

////////////////////////////////////////////////

<?php if ($module['position'] == 'header') { ?> // in admin/view/slideshow.tpl
            <option value="header" selected="selected"><?php echo $text_header; ?></option>
            <?php } else { ?>
            <option value="header"><?php echo $text_header; ?></option>
            <?php } ?>

然后,定义了幻灯片的新位置.您可以在管理页面中选择它.

Then a new position for slideshow has been defined. and you can choose it in the admin page.

之后,您应该将这些代码添加到catalog/view/header.tpl

After that, you should add those codes in catalog/view/header.tpl

 <?php foreach ($modules as $module) { ?>
    <?php echo $module; ?>
    <?php } ?>

然后,在catalog/controller/header.php中,添加一些类似于content_top.php的代码: $ layout_id = 1;

Then, in the catalog/controller/header.php, add some codes like content_top.php does: $layout_id = 1;

$module_data = array();

$this->load->model('setting/extension');

$extensions = $this->model_setting_extension->getExtensions('module');      

foreach ($extensions as $extension) {
    $modules = $this->config->get($extension['code'] . '_module');

    if ($modules) {
        foreach ($modules as $module) {
            if ($module['layout_id'] == $layout_id && $module['position'] == 'header' && $module['status']) {
                $module_data[] = array(
                    'code'       => $extension['code'],
                    'setting'    => $module,
                    'sort_order' => $module['sort_order']
                );              
            }
        }
    }
}

$sort_order = array(); 

foreach ($module_data as $key => $value) {
    $sort_order[$key] = $value['sort_order'];
}

array_multisort($sort_order, SORT_ASC, $module_data);

$this->data['modules'] = array();

foreach ($module_data as $module) {
    $module = $this->getChild('module/' . $module['code'], $module['setting']);

    if ($module) {
        $this->data['modules'][] = $module;
    }
}


if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
} else {
    $this->template = 'default/template/common/header.tpl';
}

$this->render();

然后全部完成.

此代码的唯一问题是幻灯片不能显示为幻灯片,而是静态图片.

The only problem for this code is the slideshow cannot display as a slideshow but a static picture or pictures.

希望您能解决并回复我. 我的问题贴: Opencart开发:更改幻灯片的位置

Wish you could solve it out and reply to me. My question post: Opencart developement: change slideshow's position

这篇关于opencart 1.5如何在标题中添加模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆