我想通过从模块中选择来添加图像作为背景。新的扩展名将在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'] = '';
}
在目录/视图/主题/默认/模板/common/header.twig中
{{ headbg }}
非常感谢,
您在此处检查的文件https://github.com/bblori/OpenCart3-Module-Header-Image
答案 0 :(得分:0)
我是opencart的新手,但根据您在表单中看到的内容,该输入名为headbg
<input type="hidden" name="headbg" value="{{ config_headbg }}" id="input-headbg" />
,然后在管理控制器中检查config_headbg if (isset($this->request->post['config_headbg']))