gr4devel Posted May 6, 2013 Share Posted May 6, 2013 (edited) Hi community I'm currently migrating some modules that I've made to the bright new version of PS (i.e. 1.5.4.1). Concurrently I'm doing some refactoring and so I want to know if there is a "right" and safe way to check, inside a module, if it is mounted in the product page. Currently the module I'm talking about hooks into the header and, if the current page is a product page, then add a JS that automatically fetch via AJAX some data from a wordpress blog. The page check is done by looking at the smarty property paga_name. Is there a better way to check the page or in general to achieve what I'm trying to do? Please I really want to have a safe, performance code inside the modules that I'm porting. Thanks . Edited May 24, 2013 by gr4devel (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 6, 2013 Share Posted May 6, 2013 you want to check page from: .tpl file or maybe from .php script im asking because it's important in this case anyway - your method is good, you can also add restrictions in the modules -> positions, find your module on list and click on edit icon, then you will be able to add restrictions (exceptions) Link to comment Share on other sites More sharing options...
Paul C Posted May 6, 2013 Share Posted May 6, 2013 I don't know about the "right" way but you can use the context variable. e.g. something like: if ($this->context->controller instanceof ProductController) { // Do something that should only happen on the product page } 2 Link to comment Share on other sites More sharing options...
gr4devel Posted May 6, 2013 Author Share Posted May 6, 2013 (edited) Sorry I didn't specified clearly . All I've written refers to the controller layer (i.e. .php of the module) and not the view (i.e. it's .tpl). Thank you very much for your quick response and for your kindness Edited May 6, 2013 by g11111g (see edit history) Link to comment Share on other sites More sharing options...
gr4devel Posted May 6, 2013 Author Share Posted May 6, 2013 You're right Paul! ...I'm such an idiot... I'm not already get used to the new Context object. Sorry, I'll try to get what I need following your advice. Actually I can't test your solution because of the lack of data in my shop so I'll leave this topic unsolved until I test. For the moment let me thank you together with vekia who is always there to help reckless developer like me! Link to comment Share on other sites More sharing options...
gr4devel Posted May 24, 2013 Author Share Posted May 24, 2013 Ok it seems to be solved, thanks again to everyone!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now