Cuando estamos trabajando con Magento, en ocasiones necesitamos conocer si actualmente nos encontramos en la home de nuestro sitio o en cualquier otra página. Normalmente, la home, tendrá un diseño diferente y por eso debemos diferenciarla de las demás.
Para ello, desde Magento 1.5+ tenemos una función que nos puede ayudar mucho en esta misión. Si nos encontramos en el header.phtml podemos comprobarlo llamando a:
1 2 3 4 | if ($this->getIsHomePage()) echo "Estoy en la HOME"; else echo "No estoy en la HOME"; |
Pero si nos encontramos en cualquier otra plantilla, tenemos que llamar a esa misma función que se encuentra en el header, para ello obtenemos el singleton del header y se lo preguntamos:
1 2 3 4 | if (Mage::getBlockSingleton('page/html_header')->getIsHomePage()) echo "Estoy en la HOME"; else echo "No estoy en la HOME"; |
O también podemos asignar el valor de Mage::getBlockSingleton(‘page/html_header’)->getIsHomePage() a una variable local y utilizar su valor en nuestra plantilla.
Actualización 23/02/2015 15:25 : Arreglado el segundo código que no salia bien.







Pingback: Magento: Saber si estamos en la página principal (home page) | PlanetaLibre /
Pingback: Magento: Conocer qué página de CMS se está visualizando ahora mismo | Poesía Binaria /
Pingback: Un buen 2015 para el blog. Los posts que han marcado el año y consultas SQL – Poesía Binaria /
This is really a great website, i suggest you to post articles to attract visitors attention. Your website is really a great source of information.Elon musk Black Leather jacket
Wonderful article. Fascinating to read. I love to read such an excellent article. Thanks! It has made my task more and extra easy. Keep rocking.
Stranger Things Bomber Jacket
Thanks a lot for sharing us about this update. Dofollow blog commenting Hope you will not get tired on making posts as informative as this.
I am extremely delighted in for this web journal. Its a useful subject. It help me all that much to take care of a few issues. real estate investment online Its chance are so awesome and working style so rapid.
Waow this is quite pleasant article, my sister love to read such type of post, piggyvest
I am going to tell her and bookmarking this webpage. Thanks
Great article with excellent idea!Thank you for such a valuable article. tech I really appreciate for this great information..
This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and Dofollow blog commenting keep on sharing more … good luck.