郎朗坤
例如,拉特说我们需要在精选模块中添加图像。转到/admin/view/template/extension/module/featured.php几乎在 内部的任何位置public function index() { ... }(可能在之后$this->load->model('setting/module');和之前$this->response->setOutput($this->load->view('extension/module/featured', $data));)添加以下内容。我之前已经添加过if (isset($this->request->post['top'])) {if (isset($this->request->post['image'])) { $data['image'] = $this->request->post['image'];} elseif (!empty($module_info)) { $data['image'] = $module_info['image'];} else { $data['image'] = '';}$this->load->model('tool/image');if (isset($this->request->post['image']) && is_file(DIR_IMAGE . $this->request->post['image'])) { $data['thumb'] = $this->model_tool_image->resize($this->request->post['image'], 100, 100);} elseif (!empty($module_info) && is_file(DIR_IMAGE . $module_info['image'])) { $data['thumb'] = $this->model_tool_image->resize($module_info['image'], 100, 100);} else { $data['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);}$data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);比,在/admin/view/template/extension/module/featured.twig中找到<div class="form-group"> <label class="col-sm-2 control-label" for="input-name">{{ entry_name }}</label> <div class="col-sm-10"> <input type="text" name="name" value="{{ name }}" placeholder="{{ entry_name }}" id="input-name" class="form-control" /> {% if error_name %} <div class="text-danger">{{ error_name }}</div> {% endif %} </div></div> 并在后面添加<div class="form-group"> <label class="col-sm-2 control-label">{{ entry_image }}</label> <div class="col-sm-10"><a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"><img src="{{ thumb }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a> <input type="hidden" name="image" value="{{ image }}" id="input-image" /> </div></div>现在应该可以了。