Post by oliwin » Sun Oct 29, 2017 9:05 am

I tried to modify home controller adding new variable:

Code: Select all

$data["header_home"] = true;
Then I try to check this in header.twig tetmplate like as:

Code: Select all

{% 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

Code: Select all

<div>Home</div>.
How to fix it, what do wrong?

This is home controller:

Code: Select all

<?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));
    }
}

New member

Posts

Joined
Tue Jan 10, 2017 2:00 am

Post by cyclops12 » Sun Oct 29, 2017 5:41 pm

Wouldnt it be easier to install the HTML extension and add it to the home page in Layouts ?

Active Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by oliwin » Mon Oct 30, 2017 3:04 am

It is not suitable for me. I need to do that using controller

New member

Posts

Joined
Tue Jan 10, 2017 2:00 am
Who is online

Users browsing this forum: No registered users and 9 guests