Reputation: 158
Does OpenCart Version 2.3.0.2 have some methods to check in header or footer .tpl files that current page is product? Example if (is_product) { // do something }
Upvotes: 2
Views: 930
Reputation: 3000
No, But you can create it.
File:
catalog/controller/common/header.php
Find:
return $this->load->view('common/header', $data);
Add Before:
$data['is_product'] = isset($this->request->get['route']) && $this->request->get['route'] == 'product/product';
File:
catalog/view/theme/default/template/common/header.tpl
Add where you need:
<?php if (!empty($is_product)) { ?>
<p>This is the product page</p>
<?php } else { ?>
<p>This is not the product page</p>
<?php } ?>
Upvotes: 1
Reputation: 1430
You can try to check if your session has product. $this->session->data['product_id']
You can check it anywhere. You can write the product to the session... for example:
$this->session->data['product_id'] = /*your product_id*/;
And now you can retrieve this product anywhere.
Upvotes: 2