Jump to content

Override a module FrontController


Gary - WIC

Recommended Posts

Hi !

 

Is there a way to override a ModuleFrontController from a module ?

 

I know that is possible to override a module main file via override/modules folder, but is it possible to override a frontcontroller for a specific module ? (In my case I need to override LoyaltyDefaultModuleFrontController)

 

Thanks for any help,

 

Gary

Link to comment
Share on other sites

i know that is not a perfect solution,

but you can duplicate this controller, change its name

and in other files change original controller name to your duplicated one 

 

you will avoid problems with module upgrade then :-)

Link to comment
Share on other sites

  • 7 months later...

Put this file into override/classes/.

Then delete cache/class_index.php

This allow override front controller of modules.

 

Example:

override/modules/productscomment/controllers/front/default.php

 

class ProductCommentsDefaultModuleFrontControllerOverride extends ProductCommentsDefaultModuleFrontController {

..............

}

 

 

Tested on PS 1.6.1.4

 

 

Sorry for my bad english.

Best regards, Alex.

 

Dispatcher.zip

  • Like 1
Link to comment
Share on other sites

Thx for the script alexdee2007, Tried it, however  ¿how should i modify it to be able to override an module adminController?

 

I want to override  modules/mymodule/controllers/admin/AdminMyModuleSomeController.php

Class name in this file:

class AdminMyModuleSomeController.php extends ModuleAdminController
{...

My override file:

class AdminMyModuleSomeControllerOverride extends AdminMyModuleSomeController
{...

Also i need to override main php file so  i put the override file in

/override/modules/mymodule/mymodule.php 

 

 

Then: 

- i've copied Dispatcher.php to /override/classes/

- i've copied override file to /override/modules/mymodule/controllers/admin/AdminMyModuleSomeController.php

- delete class_index.php from cache

 

¿is that right? I'm afraid im losing something here cause it does not work

 

Thx in advance!!

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

Hello! This feature allows to override only Front Controllers, not Admin Controller.

If you need override Admin Controller, i have been made some changes in file Dispatcher.php.

Also you need put file AdminController.php into override/classes/controller

 

Then delete cache/class_index.php

This allow override front and admin controllers of modules.

 

Best regards, Alex.

override.zip

  • Like 1
Link to comment
Share on other sites

  • 1 month 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...