Extending a core module using overrides
Permalink
Hi all,
I have version 5.6.3.1 and I try to override a core module, namely ROOT/core/controllers/blocks/form.php
Following instructions herehttp://www.concrete5.org/documentation/how-tos/developers/overridin... and discussions here:http://www.concrete5.org/community/forums/customizing_c5/override-c... , I have disabled all possible cache, cleared the cache and added a file in /ROOT/controlers/blocks/form.php that contains the following code:
The override appears as "overrides: controllers/blocks" in dashboard->environment.
If I put the same file in /ROOT/controlers/form.php it appears in dashboard/environment as "overrides: controllers/form.php
In both scenarios the override is not executed and I grew some white hair trying to find out why. IMHO it should appear as "overrides: controllers/blocks/form.php" in dasboard->environment to function but I run of ideas of where to place the file, or if I need to place another one too somewhere else.
Any help is welcome.
Lian
I have version 5.6.3.1 and I try to override a core module, namely ROOT/core/controllers/blocks/form.php
Following instructions herehttp://www.concrete5.org/documentation/how-tos/developers/overridin... and discussions here:http://www.concrete5.org/community/forums/customizing_c5/override-c... , I have disabled all possible cache, cleared the cache and added a file in /ROOT/controlers/blocks/form.php that contains the following code:
The override appears as "overrides: controllers/blocks" in dashboard->environment.
If I put the same file in /ROOT/controlers/form.php it appears in dashboard/environment as "overrides: controllers/form.php
In both scenarios the override is not executed and I grew some white hair trying to find out why. IMHO it should appear as "overrides: controllers/blocks/form.php" in dasboard->environment to function but I run of ideas of where to place the file, or if I need to place another one too somewhere else.
Any help is welcome.
Lian
Hi Antti,
I thought there is no point in getting too deep in docs as I need to do this only once and the instructions found for overriding seemed quite clear (which they weren't, unfortunately). Besides, I thought that overriding a method in a module has not much to do with creating your own block. So, laziness...
As for the structural change in the next version, it is quite sad, because it means that the whole overriding concept is thrown to the bin... I wanted to use overrides especially because I wanted to have no problem in case of upgrades.
If the structure is changing it means it is pretty much the same now if I do it using overrides or add the few lines of code directly in the core file and make a note somewhere that I should re-add them after each upgrade.
Frankly, I will probably keep the site un-updated as long as possible when the new version is out, just to be sure it's working. I know that is not "wise" but I had an C5 upgrade about 2 years ago that broke 4 sites in a snap, and got lots of complains from the customer for the days I needed to find out why, using the forums.
Cheers,
Lian
I thought there is no point in getting too deep in docs as I need to do this only once and the instructions found for overriding seemed quite clear (which they weren't, unfortunately). Besides, I thought that overriding a method in a module has not much to do with creating your own block. So, laziness...
As for the structural change in the next version, it is quite sad, because it means that the whole overriding concept is thrown to the bin... I wanted to use overrides especially because I wanted to have no problem in case of upgrades.
If the structure is changing it means it is pretty much the same now if I do it using overrides or add the few lines of code directly in the core file and make a note somewhere that I should re-add them after each upgrade.
Frankly, I will probably keep the site un-updated as long as possible when the new version is out, just to be sure it's working. I know that is not "wise" but I had an C5 upgrade about 2 years ago that broke 4 sites in a snap, and got lots of complains from the customer for the days I needed to find out why, using the forums.
Cheers,
Lian
In your override you need to do:
You will probably also need to redeclare the other classes that are declared in the core FormBlockController file.
class FormBlockController extends Concrete5_Controller_Block_Form { function action_submit_form() { } }
You will probably also need to redeclare the other classes that are declared in the core FormBlockController file.
Hi John,
Indeed, you're right, I had to redeclare one more class (the MiniSurvey) and this was quite simple after having my file in the right position and with the right name, as it complained directly in browser that it couldn't find the MiniSurvey one.
Cheers,
Lian
Indeed, you're right, I had to redeclare one more class (the MiniSurvey) and this was quite simple after having my file in the right position and with the right name, as it complained directly in browser that it couldn't find the MiniSurvey one.
Cheers,
Lian
Thank you very much guys, to both of you. It works now!
Indeed the file position and name should have been:
/blocks/form/controller.php
and its content is:
I'll try to mark both the answers as best, don't know if it works this way :)
Cheers,
Lian
Indeed the file position and name should have been:
/blocks/form/controller.php
and its content is:
I'll try to mark both the answers as best, don't know if it works this way :)
Cheers,
Lian
http://www.concrete5.org/documentation/developers/blocks/understand...
And I would also suggest learning the directory structure in 5.6 and older:
http://www.concrete5.org/documentation/developers/system/directory-...
The override needs to be placed in:
/blocks/form/controller.php
NOTE: The structure will change in 5.7, so this is just a note to some future readers that this is for 5.6 and versions before that.
Antti / Mainio