Page 1 of 1

Best way to protect customised module code?

Posted: Sun Jul 24, 2011 10:04 pm
by sjo123
What is the best way to protect customised modules from being over-written when a module upgrade takes place?

Can you put customised module files in /module_custom as you can with land and template files?

Re: Best way to protect customised module code?

Posted: Sun Jul 24, 2011 10:10 pm
by M@rtijn
it actually is module_custom and yes you can, but...

..most of the time when there is a upgrade to a module, the entire code or parts of it will be rewritten, deleted or added. Therefore a custom_module file will not work properly overtime and is not really handy.

I have a simple text file with the code i've 'rewritten' (actually they are more simple sql queries I want different than standard) which I manually change when a module updates, that way you can control it better.
(tip: the brilliant module 'OwnersManual', you'll get an extra page in your admin panel where you can store these 'code changes')

Re: Best way to protect customised module code?

Posted: Sun Jul 24, 2011 10:59 pm
by sjo123
So do you need to change anything to get the /module_custom/Products/foo.php file picked up instead of the standard module file?

Re: Best way to protect customised module code?

Posted: Mon Jul 25, 2011 4:25 pm
by Wishbone
I don't believe that you can use module_custom for PHP changes.. I believe I tested this, and you can only use lang and template overrides in this area.

Re: Best way to protect customised module code?

Posted: Mon Jul 25, 2011 4:27 pm
by M@rtijn
Sorry, I stand corrected.
It is indeed not possible to have custom php files.

Re: Best way to protect customised module code?

Posted: Mon Jul 25, 2011 4:34 pm
by Wishbone
One little trick I have done is to add a template into the module_custom area that calls a plugin or UDT, then includes the original template... In this UDT, I can do whatever I want, database calls, etc, then modify existing template variables, and in this way modify some aspects of the original code without having to hack it. One example would be adding GBFilePicker to the default news article submission template.