Jump to content

[SOLVED] Right check if in product page


gr4devel

Recommended Posts

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 by gr4devel (see edit history)
Link to comment
Share on other sites

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

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
}

  • Like 2
Link to comment
Share on other sites

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! :D

Link to comment
Share on other sites

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...