Jump to content

[solved] How to? Module action on disable?


El Patron

Recommended Posts

Hi, pretty darn new...but I love creating little modules and have a question.

 

When my module installs it backs up the original .tpl file and creates a new .tpl file. When it is asked to un-install it will properly replace the modules .tpl file with the original.

 

But when I disable the module from the module manager I have no function like uninstall. So disabling the module has no affect.

 

I looked into some production modules to try and see what code there is to handle module disable but I don't see anything. Please note: the module is not hooked and is a simple replace/restore of a .tpl.

 

Could someone set me straight? :) an example would be very much appreciated.

 

Cheers,

 

Fred

Link to comment
Share on other sites

a module that you create extends the class called Module. inside the Module class is a function called disable()

    public function disable()
   {
       return Module::disableByName($this->name);
   }

 

extend this function by adding it to your class and perform the action you need prior to the return statement.

so something like....

    public function disable()
   {
    //do your tpl rename here.

    return Module::disableByName($this->name);
   }

Link to comment
Share on other sites

a module that you create extends the class called Module. inside the Module class is a function called disable()

	public function disable()
{
	return Module::disableByName($this->name);
}

 

extend this function by adding it to your class and perform the action you need prior to the return statement.

so something like....

	public function disable()
{
	//do your tpl rename here.

	return Module::disableByName($this->name);
}

 

Thank you so very much!

Link to comment
Share on other sites

dont have, becouse when disable, dont call to a module function inside. ANd is a bad idea replace a tpl of other module. YOu dont find other way to do?

 

Hola rsi, very reasonable argument and I would tend to agree with you, but we really don't replace the clients .tpl, we simply patch the existing currents themes .tpl.

 

My assumption (please correct me) is that disable only works for hooked modules . Our module is not hooked. So when disabled either from our configuration or module manger, we need to replace the original .tpl.

 

I'm hoping to learn the 1.4 environment now and look forward to more overrides in 1.5. :)

 

I used this as my guide: http://doc.prestasho...estaShop+module

it does not take into account disable/enable handling within a module. Maybe someday I can contribute to the document.

Link to comment
Share on other sites

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...