Welcome Guest, Not a member yet? Register   Sign In
code reuse: wich is the best approach for sharing controllers and views between different projects?

[eluser]Bad Penguin[/eluser]
I'm thinking to migrate a wordpress blog network to a custom app created with C.I.;
the main advantage will be that i'll be able to control everything from a unique DB
and of course speed: 1 query to render a page instead of like 100 queries that WP does :-P

To do that i wish to reuse as much as possible the source code of controllers and views:
wich is the best approach to do so?

For views i was thinking to use a config variable to choose a theme/layout, so my default view will be something like /application/views/$myvar/homepage.php
I've only 3 layout out of 30 domains.

For controller looks way more complicated, it seems that everything must be created inside /application/core/MY_Controller.php and then in every domain i extend this core class with the small adjustment i need for each domain.

What do you suggests?

Thanks, Antonio :red:

If you are hosting all of these sites off of the same server / CI install, Packages might be useful for you.

The way I would set it up, the MY_Controller would have the logic for figuring out what website is being called, and then call all of that website's relevant files / info.

It really depends on your end goal, how much is and isn't shared between the websites. That's the nice thing about Packages, because they can contain configs, controllers, views, etc., all in individual folders for easy compartmentalization.

Theme © iAndrew 2016 - Forum software by © MyBB