Jump to content

Improvement: assign a module to a specific page


Recommended Posts

In the backend of Prestashop you can make an exception for modules in : Modules> posistion > edit.

 

It would be great if you can also assign an module to a specific page. So you don't have to fill in all the execeptions if you want a module to show up in just one page...

  • Like 1
Link to comment
Share on other sites

This a a good DIY change, which is not very hard.

 

Look in the main module file module_name.php and find the hook you want to restrict.

 

Based on your PS version, get the variable $page_name (you can search for it in other files and see how it is invoked / used).

Then simply add the following at the top of the hook function

if ($page_name != 'category') // replace category with any page name
   return;

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hey

 

I'm still having real trouble with this. I've tried the solution given by tomerg3 but can't find the exact piece of code he's changing in my homecategories.php file. I've looked for reference at the other page restricted modules i.e. my slider carousel and homefeatured.php and neither reference $page_name. In fact i can't work out how they're being restricted at all. Def just me being thick but i'd really appreciate some help...

 

Ta

 

James

Link to comment
Share on other sites

  • 3 months later...

I can only get this to work in index... anything else returns a white screen

 

so I have a custom html module I want to show on the left that is specific based on primary category, is that possible?

 

how would that link work?

 

" {if $page_name == index} " works for index but if my category id is 9 how would that look?

Link to comment
Share on other sites

×
×
  • Create New...