简体   繁体   English

来自模块的OpenCart 3标题图像

[英]OpenCart 3 header image from module

I would like to add an Image as background by selecting from a module. 我想通过从模块中选择来添加图像作为背景。 The new extension is created under starter_module name. 新扩展名在starter_module名称下创建。

Please, do not suggest to add image in css file. 请不要建议在css文件中添加图像。

The image set in module is not saving, this would be the issue, if you know the solution, please add in your comment. 模块中设置的图像未保存,这将是问题,如果您知道解决方案,请在评论中添加。

Many thanks, 非常感谢,

I added in: admin/view/template/extension/module/starter_module.twig 我添加了: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>

In admin/controller/extension/module/starter_module.php 在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

In catalog/controller/common/header.php 在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'] = '';
}

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


{{ headbg }}

Many thanks, 非常感谢,

The files you check here https://github.com/bblori/OpenCart3-Module-Header-Image 你在这里检查的文件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