问题
I tried to modify home controller adding new variable:
$data["header_home"] = true;
Then I try to check this in header.twig tetmplate like as:
{% if header_home %}
<div>Home</div>
{% else %}
<div>Not Home</div>
{% endif %}
When I open home page by index.php or just url address it does not work, I mean I dont see <div>Home</div>
.
How to fix it, what do wrong?
This is home controller:
<?php
class ControllerCommonHome extends Controller {
public function index() {
$this->document->setTitle($this->config->get('config_meta_title'));
$this->document->setDescription($this->config->get('config_meta_description'));
$this->document->setKeywords($this->config->get('config_meta_keyword'));
if (isset($this->request->get['route'])) {
$this->document->addLink($this->config->get('config_url'), 'canonical');
}
$data["header_home"] = true;
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/home', $data));
}
}
回答1:
Log in to your backend, on your dashboard there will be a settings option.
After you click on it you would see Developer Settings.
Click on Refresh for Theme. Now reload you home page and check if you can see <div>Home</div>
.
来源:https://stackoverflow.com/questions/46983964/display-block-html-only-on-main-page