仅在主页上显示块 HTML?
Display block HTML only on main page?
我尝试修改家庭控制器添加新变量:
$data["header_home"] = true;
然后我尝试在 header.twig 模板中检查它,如下所示:
{% if header_home %}
<div>Home</div>
{% else %}
<div>Not Home</div>
{% endif %}
当我通过 index.php 或 url 地址打开主页时它不起作用,我的意思是我没有看到 <div>Home</div>
。
如何解决,哪里出错了?
这是家庭控制器:
<?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));
}
}
登录到您的后台,在您的仪表板上会有一个设置选项。
点击后你会看到开发者设置。
单击刷新 主题。现在重新加载您的主页并检查您是否可以看到 <div>Home</div>
.
我尝试修改家庭控制器添加新变量:
$data["header_home"] = true;
然后我尝试在 header.twig 模板中检查它,如下所示:
{% if header_home %}
<div>Home</div>
{% else %}
<div>Not Home</div>
{% endif %}
当我通过 index.php 或 url 地址打开主页时它不起作用,我的意思是我没有看到 <div>Home</div>
。
如何解决,哪里出错了?
这是家庭控制器:
<?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));
}
}
登录到您的后台,在您的仪表板上会有一个设置选项。
点击后你会看到开发者设置。
单击刷新 主题。现在重新加载您的主页并检查您是否可以看到 <div>Home</div>
.