opencart - 来自模块的 OpenCart 3 标题图像
问题描述
我想通过从模块中选择来添加图像作为背景。新扩展在 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
在目录/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'] = '';
}
在目录/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_headbgif (isset($this->request->post['config_headbg']))
推荐阅读
- python - 无法使用 scrappy 从网站上抓取文本
- reactjs - React - 如何在一个 scss 文件中导入所有 scss 文件
- sql - 我的查询中的 where 语句应该只返回今天和昨天的日期,但仍返回较早的日期
- node.js - Nestjs导入依赖无法导入我的服务
- sql - 执行 GROUP BY 后如何基于算术运算创建新列
- sh - `pwd` 曾经有一个 `-W` 选项吗?
- php - PHP 看不到 Tesseract OCR
- twilio - Twilio API 导出子帐户
- asp.net-mvc - 剑道甘特时间线以 30 分钟为增量?
- r - 将每个主题的输出指定为特定数量的单词