By default top page menu is regulated by two types of hooks: Top and Home. The Home hook is used when you need your content to be available on the homepage only, while the Top hook is responsible for all other pages.
But what should we do if we need some content to be available both on the homepage and some other page, although not all of them? In this case we need to verify the controller in the Top hook. The following method can be used for this task:
Partner With Us
Let's discuss how to grow your business. Get a Free Quote.
Talk to Vlad
1 2 3 4 5 6 7 8 9 10 |
public function getCurrController() { if (!Tools::getValue('fc')) { if ($controller = Tools::getValue('controller')) { return $controller; } } return 'index'; } |
It will return index for the homepage.
This method should be declared in the class which contains the module. For instance, you can make the following verification in the Top hook:
1 2 3 4 5 6 7 8 9 10 11 |
if ($this->getCurrController() == 'index') { //this is the homepage } if ($this->getCurrController() == 'catalog') { //catalog page } if ($this->getCurrController() == 'product') { //product page } |
Partner With Us
Looking for a partner that will help you to grow your business? We are the right company to develop your webstore. Feel free to get in touch with us. We will be happy to discuss your business opportunities and provide you with a Free Quote.
Talk to Vlad