My 2¢

If you are pretty happy with the setup and it works for you there is a
quick way to minimize code-duplication. Your sub controllers should
extend the main news controller. (you will have to add a App::import()
at the top of these files so that news controller can be found) THen
you can probably tweak your code to read site-specific stuff from
class attributes you have set and possible one or two overridden
methods.

If you can to mote to a single controller, that should be possible
too. Your route could add a named parameter that the controller can
read and understand which sub-site it is in. Custom data for that site
can them be loaded from a statis lookup table (array) in the class or
from a database table. You could probably even just get away with
using the parameter the rout sets directly as the foldername for views
and site "id" for storing news. But it all depends in exactly how they
differ.

/Martin

On Jun 3, 3:40 am, double07 <[email protected]> wrote:
> Hi All,
>
> I'm working on a project at the moment which has a main site then sub
> sites for venue franchises. The venue sub sites are effectively the
> same as the main site but the news items etc are filtered to be only
> for that particular venue.
>
> The way I have this setup at the moment is as follows (I'll use news
> as an example):
> -Just a standard news model
> -a main controller for news news_controller.php
> -a sub controller for each venue i.e. venue1_news_controller.php -
> this is the same as the normal news controller except it has a
> condition to filter only news items for 'venue1'
> -normal news views
> -a venue1 sub folder in news containing slightly different views
> (mainly to add a hidden venue id field when adding news so when a
> venue1 editor can only add news for venue1) - accessed in the venue1
> news controller via changing the view path
> -Then I have routes setup ie: Router::connect('/venue1/news/:action/
> *', array('controller' => 'venue1_news'));
>
> Now this all works perfectly fine. However, what concerns me is the
> amount of times I'm effectively repeating things which are - bar a few
> small differences - doing essentially the same thing. Also, if I have
> to make changes to the news controller I effectively have to update
> each sub controller too.
>
> I'm just wondering if this is the best way to go about things? Is
> there a better way where I could have only one news controller/set of
> views but somehow add the conditions for the venues on the fly or
> something?
>
> Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to