仅在主页上显示块HTML? [英] Display block HTML only on main page?

查看:106
本文介绍了仅在主页上显示块HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过添加新变量来修改家庭控制器:

I tried to modify home controller adding new variable:

$data["header_home"] = true;

然后我尝试在 header.twig tetmplate中对此进行检查,如下所示:

Then I try to check this in header.twig tetmplate like as:

{% if header_home %}
    <div>Home</div>
    {% else %}
<div>Not Home</div>
{% endif %}

当我通过index.php打开主页或只是URL地址不起作用时,我的意思是我没有看到<div>Home</div>.

When I open home page by index.php or just url address it does not work, I mean I dont see <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));
    }
}

推荐答案

登录到后端,您的仪表板上将提供一个设置选项.

Log in to your backend, on your dashboard there will be a settings option.

点击后,您会看到开发者设置.

点击刷新以查看主题.现在重新加载您的主页,并检查是否可以看到<div>Home</div>.

Click on Refresh for Theme. Now reload you home page and check if you can see <div>Home</div> .

这篇关于仅在主页上显示块HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆