On Jan 15, 2007, at 3:16 PM, sentel wrote:
Hi All,
first, I'm a bit of a newby to cakephp, but already loving it.
I made some models, associations, controllers etc and I'm still using
scaffolding (suites for now) to manage the contents of the database.
Then I made some pages wich soon became something like a website.
I came across a problem: How to pass data from the database (using the
models) to the pagescontroller.
I'm almost sure that there has to be a simple way to do that.
At the moment I used the following as a solution:
I created a basic page model and copied the pages controller from the
lib/controllers directory to my own controllers directory. In the
pages
controller I made var $uses = array('Package') ... (the model I
want to
use) and then $this->set('packages',$this->Package->findAll());
Now I can use the data from the Package model.
Is this the way or is there a standard way to do this?
Usually the PagesController is used only for static content delivery.
That said, you've just created a controller with models tied to a
view... something that everyone should do all the time.
Another way could be to extend the PagesController, but what name
should I give it and in what file does that go. That way I can avoid
copying the pages_controller file.
Just create your own PackagesController, that already has access to
the Package model.
-- John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---