Opencart开发:改变幻灯片的位置
我正在与 opencart 合作。 我想将幻灯片从“内容顶部”更改为“标题”。 这意味着,我想将幻灯片移至顶部菜单上方,并且它还将显示在每个页面中,而不是仅显示在主页中。
我已完成以下步骤: 第一:在管理三个“slideshow.php”文件(控制器、语言和视图文件夹)中添加一个名为“header”的位置。 第二:我修改了 header.php:(在控制器文件夹中的“//menu”代码块之后添加这些代码)
$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();
第三:在 header.tpl 文件中添加代码:仍然在“//menu”代码块之前。 (在视图文件夹中)
<div>
<?php foreach ($modules as $module) { ?>
<?php echo $module; ?>
<?php } ?>
</div>
现在,问题是: Banner.tpl 中的 JavaScript 代码将不再运行。 不过幸运的是,slideshow.tpl 中的 JavaScript 代码仍然可以运行。
因此,目前网站在主页菜单之前的标题位置显示横幅,但幻灯片效果不会。 如果您设置两张照片,它们都会显示在首页。他们不会再彼此改变。
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.
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: 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>
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,你不能只是继续复制过去,
你应该明白你将做什么
幻灯片放映是 slidshow.tpl 和 Slideshow.php
要包含 javascript,您需要在 /controller/commun/header.php 中添加以下代码行
$this->document->addScript('catalog/view/javascript/jquery/nivo-slider/jquery. nivo.slider.pack.js');
这样 JavaScript 就可以工作了
first of all u can't just go ahead and copy past
you should understand what you will do
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');
so the javascript can work
您可以使用一个简单的模块来添加这些位置并保持 javascript 正常工作。
http://www.opencart.com/index .php?route=extension/extension/info&token=extension_id=14467
您还可以添加无限数量的位置、添加列并更改宽度,它适用于所有主题和模块。
问候
you can use a simple module for that that adds these positions and keeps the javascripts working proparly.
http://www.opencart.com/index.php?route=extension/extension/info&token=extension_id=14467
Also you can add unlimited number of positions, add columns and change there width and it works with all themes and modules.
Regards