Jump to content

How to show module for only in home page


30ml

Recommended Posts

hi,

 

check the module transplant function in back-office.

when you transplant a module or edit/create a module position you can fill in the field "exceptions".

 

Fill in this field with pages (comma separated) you don't want the module to appear :

index.php (home page)

order.php (order page)

category.php (product list pages)

product.php (product page)

...

and so on

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Is there any way that if I can specify to show on only in home . Ex only home. Rather than mentioning for several page for exception. Making exception would be the current medecine but if i add next page then I have to add that page in exception and I do not know how many page I need to put on exception. Do any body know ?

Link to comment
Share on other sites

  • 4 months later...

Yes you can. In your module tpl just add the following to the top

 

{if $page_name == index}

 

then at the very bottom of your module add {/if}

 

That should work.

 

Hope that helps!

 

Marty Shue

 

The problem with this method, as has just been pointed out to me, i that the module code is still run will always be run even if the output is not displayed, which can rise to performance issues. The module will also insert any javascript and/or css it needs making it even worse!

  • Like 1
Link to comment
Share on other sites

  • 10 months later...
The module will also insert any javascript and/or css it needs making it even worse!

 

I agree, i have the same issue. But can you tell how to workaround ?

It seems that setting the css and/or js inline with the template content isn't a right way

And setting all pages but one as exception in the module managemenent isn't either.

So, isn't there a way to do it in the module code ?

 

 


...
public function hookHeader($params)
{
//only on specific page, like home or other ?
 Tools::addJS(_MODULE_DIR_.'myspecific.js', 'all');
}

Edited by creacom (see edit history)
Link to comment
Share on other sites

  • 10 years 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...