2
votes

I was used below condition of Custom Box Content Display Only for HomePage in OpenCart 1.5.6. & this is working fine.

I was used this in header.tpl file.

<?php if (!isset($this->request->get['route']) || $this->request->get['route'] == 'common/home') {?>
    /////////////////////////
    /                       /
    /                       /
    /                       /
    /      Box Content      /
    /                       /
    /                       /
    /                       /
    /                       /
    /////////////////////////
<?php } ?>

but, this is not working in OpenCart 2.0.

How can the same thing be achieved in Opencart 2.0?

1
echo $this->request->get['route'] and check for this printed value?Aleksei Matiushkin
@mudasobwa It is not working. will any other solution possible? any example? Thanks.HDP
What is not working? Did you printed out what I suggested? If yes, please share the output.Aleksei Matiushkin
In OC2.0 you can no longer access $this and the objects from registry. To access them You'd need to add $this->request->get['route'] to the array $data in controller and then use it in your template... I.e. $data['route'] = $this->request->get['route']; and then in template <?php if ($route == 'common/home') { ?>.shadyyx
@shadyyx Your example is working fine. Thanks. & also, if, When, will all pages run this code & Only not run in homepage. So, how can is it possible in template? Thanks again.HDP

1 Answers

7
votes

I have found Perfect Solution. This is perfect work .

catalog/controller/common/header.php

add

if (!isset($this->request->get['route']) || $this->request->get['route'] == 'common/home'){
$data['ishome']=1;
}

then in your header.tpl

<?php if (isset($ishome)) {?>
Our Box Content
<?php } ?>