Welcome Guest, Not a member yet? Register   Sign In
Extending the Controller, Twice
#11

[eluser]stuffradio[/eluser]
I'm curious, what situation would you want to do something like this?
#12

[eluser]AlexJ[/eluser]
Its used to run a CMS, this CMS has some default functionality and some functionality that can be extended by using a modular approach, in my V_Module I would define some basic functions:

- index()
- create()
- edit($primary_key)
- delete($primary_key)

In my V_Controller is would define these 2 functions:
- header()
- footer()

I need these in the basic controllers, but also in the V_Module.

These functions are the complete CMS, to edit rows, create them and delete them, basicly the abstract layer for all the modules.

But there are some modules that need a different approach, they dont use the default layout for some reason (to implement barcodes). I can just define a controller for that module, and overwrite the default index() function.

Writing a new module is as easy as 1,2:

1. Create new controller that uses V_Module
2. Create a new model that uses my own V_Model and pass the table name and primary key to the constructor
#13

[eluser]InsiteFX[/eluser]
The MY_Controller needs to be in the application/libaries folder.

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB