I have get an header.twig
file. I need to display this header template in home page differently than in others pages. How to do that?
Asked
Active
Viewed 820 times
0

POV
- 11,293
- 34
- 107
- 201
1 Answers
3
Make two files, header.twig and home_header.twig
In catalog/controller/common/header.php there is a function index(), this uses header.twig
Write another method for example index_home() in header.php and copy the index() body in this function (make any changes if needed)
In index_home() change
return $this->load->view('common/header', $data);
to
return $this->load->view('common/home_header', $data);
If you check functions of every controller there is a line
$data['header'] = $this->load->controller('common/header');
this will call header.twig Whichever function you need to use home_header.twig you can replace
$data['header'] = $this->load->controller('common/header');
in that function with
$data['header'] = $this->load->controller('common/header/index_home');
This will use home_header.twig

Mehravish Temkar
- 4,275
- 3
- 25
- 44
-
Can you see my question here please: https://stackoverflow.com/questions/46983964/display-block-html-only-on-main-page – POV Oct 27 '17 at 22:01
-
Okay let me check – Mehravish Temkar Oct 28 '17 at 05:10