Hi,
I'm posting my question here, because jfgreco wanted to do almost the
same thing I was thinking about. This question mainly askes if what I
am thinking is possibly, reasonable, and allowed in the MVC Pattern.

On Oct 11, 4:51 am, jfgreco <[EMAIL PROTECTED]> wrote:
> David thank you for your reply.
>
> I guess my other question is, should I be creating other controllers
> one for  each type that extend post? that way I can have different
> forms but the same underlying work.
>

If I where to consolidate data into one table to reduce duplicate
table structures for essentially the same type of item.

But "essentially meaning" not really the same of type of item does it
break MVC or Cake wenn I extend that core Modell ???

As an example so you see of what I am thinking:
A table posts (staying in jfgreco's example)

Post extends AppModel (making the normal modell for the table)

News extends Post (adding logic and associations just for News)

I know that this is normal for OO, and is used by AppModel in Cake for
site wide stuff, but can I also use it for making cleaner Modells and
Controllers by consolidated talbes, or will cake break ???

This would offcourse be extreme helpfull for holding Modells/
Controllers clean, since I would also just extend PostsController.

That way what I call adding logic and associations is done more
ressourceful and cleaner.
Because if I want News to go to an archives table, after they
outdated, and only add that table for querying when I want (searches),
I just put that extended logic in News.
And I only would have a association of hasOne "EventHandler" if the
Post was really an Event. (Else I'd have to create and destroy
associations like this no stop on the fly)

The end result would logically be one MEGA Post and PostsController
and tons of "dynamic" inserting of elements ...

Oliver

PS: This is really a question of interest I have not tryed this, but
an answer would be great bevor I give it a shot (that might be doomed
to fail, or a ton of extra work)

On Oct 11, 4:51 am, jfgreco <[EMAIL PROTECTED]> wrote:
> David thank you for your reply.
>
> I guess my other question is, should I be creating other controllers
> one for  each type that extend post? that way I can have different
> forms but the same underlying work.
>
> On Oct 10, 10:15 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
>
> > All you need to do is insert the post_type into the data array before
> > saving it to the database.
> > Either insert a hidden field into the form that you use to create the
> > post, or insert it in the controller.
>
> > $this->data['Post']['post_type'] = 'news';
> > $this->Post->save($this->data);
>
> > On 11 Oct 2008, at 10:50, jfgreco wrote:
>
> > > I am designing a CMS system and am new to CakePHP. I am porting
> > > everything to Cake from a legacy system, so I have a defined database
> > > already.
>
> > > I have a table of posts and in that table I have a column called
> > > post_type which I populate with News, Page, Event or Admin. I don't
> > > want the user to have to choose the type when posting. I want them to
> > > click a link like Post News or Post A New Page. Is there a good way to
> > > use a single base controller to build off of? I created the
> > > PostController and it works for a good base, but what is the best way
> > > to build out from there? Any ideas will be helpful.
>
> > > I consolidated into one table to reduce duplicate table structures for
> > > essentially the same type of item.
--~--~---------~--~----~------------~-------~--~----~
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