opencart 1.5 如何在标题中添加模块

发布于 2024-12-05 01:21:20 字数 46 浏览 0 评论 0原文

请有人告诉我如何在标题中定位滑块或横幅等模块,或者我们如何为模块定义其他区域。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

剑心龙吟 2024-12-12 01:21:20

嗯,我正在努力。

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

例如,如果您想将幻灯片添加到标题中,则应在

$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 } ?>

然后是一个新的幻灯片的位置已定义。您可以在管理页面中选择它。

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

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

然后,在catalog/controller/header.php中添加一些代码,如content_top.php:
$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();

然后一切就完成了。

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

希望你能解决并回复我。
我的提问帖:
Opencart 开发:更改幻灯片的位置

Well, I am working on it.

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.

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

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

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

Then all done.

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

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

泪痕残 2024-12-12 01:21:20

做华为陈写的,然后将这些添加到 header:

<script type="text/javascript" src="catalog/view/javascript/jquery/nivo-slider/jquery.nivo.slider.pack.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/slideshow.css" media="screen" />

和滑块将工作

do what Huawei Chen wrote and then add these to header:

<script type="text/javascript" src="catalog/view/javascript/jquery/nivo-slider/jquery.nivo.slider.pack.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/slideshow.css" media="screen" />

and slider will be working

摇划花蜜的午后 2024-12-12 01:21:20

您可以从controller/common/column_right.php中学习

检查模块位置(第50行),您可以将其调整为“header”:

$module['position'] == 'column_right'

设置输出(第69行),您可以将其调整为类似“header_mod”的内容:

$this->data['modules']

您需要修改管理模块以显示附加模块位置。
管理页面没有“标题”模块位置选项。

You can learn from controller/common/column_right.php

Check module position (line 50), you can adapt it to "header":

$module['position'] == 'column_right'

Set the output (line 69), you can adapt it to something like "header_mod" :

$this->data['modules']

You need to modificate module at admin to show additional module position.
There is no "header" module position options at admin page.

箹锭⒈辈孓 2024-12-12 01:21:20

您还可以使用在页眉和页脚中放置 2 个位置的扩展。它创建相同的钩子,如 column_leftcontent_top 等。

它与 VQmod 一起用于 opencart 1.5x

You can also use an extension that places 2 positions in header and footer. It create the same hooks, like column_left and content_top, etc.

it works with VQmod for opencart 1.5x

濫情▎り 2024-12-12 01:21:20

我认为这个扩展将使您的生活变得超级简单。 http://www.opencart.com/index .php?route=extension/extension/info&token=extension_id=14467

向标题添加无限数量的位置、添加列并更改宽度

您可以通过管理

I think this extension will make your life super simple. http://www.opencart.com/index.php?route=extension/extension/info&token=extension_id=14467

You can add unlimited number of positions to your header, add columns and change there width all through admin

Regards

萝莉病 2024-12-12 01:21:20

本指南帮助了我:

http:// /www.mywork.com.au/blog/create-new-module-layout-position-opencart-1-5/

我使用的是1.5.6.1 Opencart版本。

This guide helped me:

http://www.mywork.com.au/blog/create-new-module-layout-position-opencart-1-5/

I was using 1.5.6.1 Opencart version.

帅气尐潴 2024-12-12 01:21:20

我读了你所有的回答。忘记所有事情。
将任何模块调用到标头部分非常容易。

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

$this->data['YOUR_MODULE_NAME'] = $this->getChild('module/YOUR_MODULE_NAME');

现在打开标头的 .tpl 文件,该文件位于
catalog/view/theme/YOUR_THEME/template/common/header.tpl

并随时回显您想要的模块,如下所示:

就是这样。你完成了。

I read all of your answer. Forget all things.
It's very easy to call any module into header section.

Open your catalog/controller/common/header.php file

$this->data['YOUR_MODULE_NAME'] = $this->getChild('module/YOUR_MODULE_NAME');

Now Open .tpl file of header, which is located at
catalog/view/theme/YOUR_THEME/template/common/header.tpl

and echo your desire module whenever you want, like as:
<?php echo $YOUR_MODULE_NAME;?>

That's it. you are done.

香草可樂 2024-12-12 01:21:20

你必须知道,你的新职位是一个新孩子。

file: catalog/controller/common/header.php

$this->children = array(
'module/language',
'module/currency',
'module/cart'
);

添加您的新位置,如下所示:

$this->children = array(
'common/content_new',
'module/language',
'module/currency',
'module/cart'
);

现在您可以在 header.tpl 中回显您的新位置

You must know that your new position is a new child.

file: catalog/controller/common/header.php

$this->children = array(
'module/language',
'module/currency',
'module/cart'
);

add your new position, like this:

$this->children = array(
'common/content_new',
'module/language',
'module/currency',
'module/cart'
);

now you can echo your new position in your header.tpl

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文