簡體   English   中英

opencart 1.5如何在標題中添加模塊

[英]opencart 1.5 how to add module in a header

請有人告訴我如何在標題中定位滑塊或橫幅等模塊,或者如何為模塊定義其他區域。

好吧,我正在研究它。

首先,您應該在管理頁面中添加新職位。 這意味着您應該更改三個文件並在每個文件中添加一些行。

例如,如果要將幻燈片添加到標題中,則應添加新位置

$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開發:改變幻燈片的位置

做什么華為陳寫,然后將這些添加到標題:

<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" />

和滑塊將工作

您還可以使用在頁眉和頁腳中放置2個位置的擴展名。 它創建相同的鈎子,如column_leftcontent_top等。

它適用於VQmod for opencart 1.5x

您可以從controller / common / column_right.php中學習

檢查模塊位置(第50行),您可以將其調整為“標題”:

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

設置輸出(第69行),您可以將其調整為類似“header_mod”的內容:

$this->data['modules']

您需要在admin處修改模塊以顯示其他模塊位置。
管理頁面上沒有“ 標題 ”模塊位置選項。

我認為這個擴展會讓你的生活變得簡單。 http://www.opencart.com/index.php?route=extension/extension/info&token=extension_id=14467

您可以在標題中添加無限數量的位置,添加列並通過管理員更改寬度

問候

本指南幫助我:

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

我使用的是1.5.6.1 Opencart版本。

我讀了你所有的答案。 忘了一切。 將任何模塊調用到標題部​​分非常容易。

打開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

並隨時<?php echo $YOUR_MODULE_NAME;?>您的欲望模塊,如: <?php echo $YOUR_MODULE_NAME;?>

而已。 你完成了

你必須知道你的新職位是新生兒。

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中回應你的新位置了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM