I'm not sure if your use of the term 'module' was intended, but did you mean 'controller'? I say that because I've used a similar strategy when creating a multi-client portal and I had each of my clients' divided by module.

So I'd have:-

/application/default/
/application/clientX/
/application/clientY/
..etc..
/library/Myapp (for master classes like controllers)
/library/Zend (for the framework)

with controllers, views and models in each module.

My base controllers would be stored in /library/myapp like 'Myapp_Controller_Blog', 'Myapp_Controller_News' and then for each module it simply extends the base class.

e.g.

class clientX_NewsController extends Myapp_Controller_News
{
    protected $_client = 'clientx';
}

class clientY_NewsController extends Myapp_Controller_News
{
    protected $_client = 'clienty';
}

The advantage to this is that you can use the 'default' module to store all your views, models, etc., and then only add local paths to your views if you need client-specific changes to your views. Ideally you'd simply create CSS files per client to control your layouts.

Controllers and Models don't perform any path-finding as-is. With controllers you need to specify include paths through the front controller, with Models you'd need to add manual paths to your PHP include path (if you use autoloader) or via Zend_Loader (if you use that to load your models).

Hope this helps you on your way!

Hi,

I'd like to avoid code duplication in an application that will be used by several clients. Most of the Clients have the same behavior with some differences regarding the layout (css mostly), some will have the same actions with different behavior and some will have unique actions.

So I am considering using a custom router to map www.foo.com/client1/module/action to be the directed to client1 and so on.

I will probably use the info found at http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.basic to change the default route. But I need an extra advice...

In order to reduce the duplication I'd like to have something like this

/myapplication/default
/myapplication/blog
/myapplication/news
...

Each module would use the standard directory structure
/myapplication/moduleX/ (application - models/views/controllers/ config, html - css, js)

So if I try to access www.foo.com/client1/blog it will first check if there is a local implementation in /client1/blog and use it. If it does not found it will use the default one.

All modules/controllers/actions, even those not found in the client1 directory, should first try to use the local views since I can have different layouts for the clients

My question is how can I do this in an effective way or if there is a better approach.

I am not familiar but someone told me that this is similar of what zope does, 'using' everything from the upper levels until it founds something locally that overrides that.

I hope I was clear enough.

thanks.

--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "

202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com

Reply via email to