Opencart开发:更改幻灯片的位置 [英] Opencart developement: change slideshow's position

查看:226
本文介绍了Opencart开发:更改幻灯片的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与opencart合作. 我想将幻灯片显示从内容顶部"更改为标题". 这意味着,我想将幻灯片放到顶部菜单上方,它还将显示在每个页面中,而不是仅显示在主页中.

I am working with opencart. I want to change slideshow from "content-top" to "header". It means, I wanna move the slideshow above the top menu, and it will also displays in every page instead of in home page only.

我已完成以下步骤: 第一:在管理员的三个"slideshow.php"文件(控制器,语言和视图文件夹)中添加一个名为"header"的位置. 第二:我修改了header.php :(将这些代码添加到控制器文件夹中的"//menu"代码块之后)

I've done following steps: 1st: add a position named "header" in admin three "slideshow.php" files (controller, language, and view folders). 2nd: I modified header.php:(add those codes after the "//menu" code block in controller folder)

    $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();

3rd:在header.tpl文件中添加代码:仍在"//menu"代码块之前. (在查看文件夹中)

3rd: add codes in header.tpl file: still, before the "//menu" code block. (in view folder)

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

现在,问题是: banner.tpl中的javascript代码将不再运行. 幸运的是,slideshow.tpl中的javascript代码仍然可以运行.

Now, the problem is: the javascript codes in banner.tpl will not run anymore. Luckily however, the javascript codes in slideshow.tpl still run.

因此,当前,网站在首页中的菜单之前,在标题位置显示横幅,但幻灯片显示效果不显示. 如果您设置了两张照片,它们都将显示在首页上.它们将不再彼此改变.

So, currently, the website displays the banner in header position, before the menu in Home page, but the slideshow effect doesn't. If you set two photos, both of them will display in the front page. They will not change with each other any more.

推荐答案

首先,您不能继续复制过去

first of all u can't just go ahead and copy past

您应该了解您会做什么

幻灯片为slidshow.tpl和slideshow.php 要包含javascript,您需要在/controller/commun/header.php中添加以下代码行

the slide show is slidshow.tpl and slideshow.php to include the javascript you need the following line of code in your /controller/commun/header.php

$this->document->addScript('catalog/view/javascript/jquery/nivo-slider/jquery.nivo.slider.pack.js');

因此javascript可以正常工作

so the javascript can work

这篇关于Opencart开发:更改幻灯片的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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