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

Post by D3MO » Sat Jul 28, 2018 4:21 am

You need to check the route path better in header controller as you now define $data["header_home"] = true; in controller common/home. Header do not have this variable set so header twig will never have this variable as a true:) unless you will check rout in header controller and then set if route = x then $data["header_home"] = true

Custom OpenCart Extension Development. Opencart Modification and third party Exetension debugging. Just PM me... or you can browse ready made extensions to boost your opencart website instantly


Active Member

Posts

Joined
Mon Apr 04, 2011 6:57 am

Who is online

Users browsing this forum: No registered users and 13 guests