Codeigniter Class Inheritance between modules (wir

2019-06-07 01:58发布

My CI2 app is using the wiredesigns modular layout.

I have a two modules called item and product in a a folder called modules like so:

/application
    /modules
        /item
        /product

In Item I have a controller called item which starts like this.

class Item extends MX_Controller
{
    //code here
}

What do I need to do to make my products controller extend my item controller in a different module

1条回答
走好不送
2楼-- · 2019-06-07 02:23

My guess is you are trying to keep your code "DRY" (http://en.wikipedia.org/wiki/Don't_repeat_yourself) which in CI means using a common controller like a My_Controller (see: http://ellislab.com/codeigniter/user-guide/general/core_classes.html).

Check out Phil Sturgeon's take: http://philsturgeon.co.uk/blog/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY.

查看更多
登录 后发表回答