Loading JavaScript in Magento Selected Pages

Load JavaScript in Magento on some pages.

By using $this->getRequest()->getControllerName() on any of your files in template folder you would get the name of the current controller. If you are on let’s say http://somesite.domain/shop/index.php/checkout/onepage/ page, your controller name is onepage. By using the above mentioned code your result would be string “onepage“. So all you need to do is to write a simple IF statement like

<?php if($this->getRequest()->getControllerName() !== ‘onepage’) { ?>
         // your javascript statements goes here
<?php } ?>

I hope you guys find this one helpful.

2 Comments

louboutin shoes  on May 15th, 2010

209

coooooooool post,thank you for sharing

SEO India  on July 13th, 2010

220

Thanks for your nice posting keep it up, I am always looking for such types of enormous information’s.

Leave a Comment

*

Spam protection by WP Captcha-Free