Friday, January 20, 2012

Including queried information in default layout

I'm looking to create a site where I can have a navigation list on one
side of each page where the list of links is taken from a database
table.

I can create the list of links just fine in the layout, but I'm suck
looking at how I might be able to get the list out from the database.
I've been looking around the internet to see how I might be able to
work it in, but I haven't been able to find anything that would work
for sure, so I was thinking I should get some input from this group
before I continue.

The first idea I saw was to include the model in the AppController,
but I can't get that to work in the slightest. I tried putting this
in my AppController:

$this->loadModel('Sitelist');

Which breaks everything, giving me the error: "Parse error: syntax
error, unexpected T_VARIABLE, expecting T_FUNCTION in /path/to/cake/
app/Controller/AppController.php on line 36 ".

I already created a "Sitelist" model, controller and view with basic
CRUD and I'm able to edit everything fine through another page.

I've also seen the suggestion to create a component that gets included
in all of the controllers which queries the database to get the list,
which then gets used by the layout, but I haven't found anything about
that written after version 1.2.

I'm working with CakePHP 2.0.5. If anybody knows what the proper way
to get a list like this populated, please let me know.

Thanks!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: