簡體   English   中英

來自模塊的OpenCart 3標題圖像

[英]OpenCart 3 header image from module

我想通過從模塊中選擇來添加圖像作為背景。 新擴展名在starter_module名稱下創建。

請不要建議在css文件中添加圖像。

模塊中設置的圖像未保存,這將是問題,如果您知道解決方案,請在評論中添加。

非常感謝,

我添加了:admin / view / template / extension / module / starter_module.twig

<div class="form-group">
        <label class="col-sm-2 control-label" for="input-headbg">Header Image</label>
        <div class="col-sm-10">
        <a href="" id="thumb-headbg" data-toggle="image" class="img-thumbnail">
        <img src="{{ headbg }}" alt="" title="" data-placeholder="{{ placeholder }}" />
        </a>
        <input type="hidden" name="config_headbg" value="{{ config_headbg }}" id="input-headbg" />
    </div>
</div>

在admin / controller / extension / module / starter_module.php中

//Top page
// Module Image
$this->model_setting_setting->editSetting('config_headbg', $this->request->post);
// Module Image
// Module Image

if (isset($this->request->post['config_headbg'])) {
    $data['headbg'] = $this->request->post['config_headbg'];
} else {
    $data['headbg'] = $this->config->get('config_headbg');
}
$this->load->model('tool/image');

if (isset($this->request->post['config_headbg']) && is_file(DIR_IMAGE . $this->request->post['config_headbg'])) {
    $data['headbg'] = $this->model_tool_image->resize($this->request->post['config_headbg'], 100, 100);
} elseif ($this->config->get('config_headbg') && is_file(DIR_IMAGE . $this->config->get('config_headbg'))) {
    $data['headbg'] = $this->model_tool_image->resize($this->config->get('config_headbg'), 100, 100);
} else {
    $data['headbg'] = $this->model_tool_image->resize('no_image.png', 100, 100);
}
$data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);

// Module Image

在catalog / controller / common / header.php中

if (is_file(DIR_IMAGE . $this->config->get('config_headbg'))) {
    $data['headbg'] = $server . 'image/' . $this->config->get('config_headbg');
} else {
    $data['headbg'] = '';
}

在catalog / view / theme / default / template / common / header.twig中


{{ headbg }}

非常感謝,

你在這里檢查的文件https://github.com/bblori/OpenCart3-Module-Header-Image

我是opencart的新手,但是從我在表單中看到的輸入被命名為headbg <input type="hidden" name="headbg" value="{{ config_headbg }}" id="input-headbg" />在管理員控制器中檢查config_headbg if (isset($this->request->post['config_headbg']))

暫無
暫無

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

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