Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как подклюлить страницу page.php в шаблон OpenCart 3.0


AleksTim
 Share

Recommended Posts

Доброго времени!
Подскажите новичку как подклюлить страницу page.php в шаблон OpenCart 3.0. Есть шаблон ocStore 3.0 в нем есть главное меню, хочу чтобы ссылки из меню вели на ситичные страницы, но при этом на эти ситичные страницы подтягивались header и footer .

Как это сгделать?

Если меняю формат страницы на .twig и указывать путь к нему, то естественно браузер не знает что икое twig и я получаю ошибку.

Link to comment
Share on other sites


Попыился написать контроллер по аналогии с контроллером home.php

папка контроллера: catalog\controller\test\page.php

папка страницы: catalog\view\theme\default\template\test\page.twig

<?php
class ControllerTestPage 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'])) {
            $canonical = $this->url->link('test/page');
            if ($this->config->get('config_seo_pro') && !$this->config->get('config_seopro_addslash')) {
                $canonical = rtrim($canonical, '/');
            }
            $this->document->addLink($canonical, 'canonical');
        }

        $this->response->setOutput($this->load->view('test/page'));
    }
}
 

на проблема в том что к страниэто не подтягивается {{ header }} из header.twig

Edited by AleksTim
Link to comment
Share on other sites


Сгделал ик, не помогло, все равно на страницу не погрузился ни хегдер ни футер ((

В чем может быть прилина? Может кроме контроллера еещё ггде-то нужно что-то добавить?

 

 

<?php
class ControllerTestPage 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'])) {
            $canonical = $this->url->link('test/page');
            if ($this->config->get('config_seo_pro') && !$this->config->get('config_seopro_addslash')) {
                $canonical = rtrim($canonical, '/');
            }
            $this->document->addLink($canonical, 'canonical');

        }
        
        $data['footer'] = $this->load->controller('common/footer');
        $data['header'] = $this->load->controller('common/header');

        $this->response->setOutput($this->load->view('test/page'));
    }
}
 

Edited by AleksTim
Link to comment
Share on other sites


Разобрался
Дело было в этот строке:

        $this->response->setOutput($this->load->view('test/home', $data));

Забыл передать в неё массив $data )
Спасипотому что!

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.