You need to place the loadmodel within a method - such as beforeFilter. Also you will benefit from learning how php classes work.
- S On 20 Jan 2012 17:51, "Dave D" <its.dave.daw...@gmail.com> wrote: > The loadmodel line is the one that gets the error. I copied and > pasted the AppController.php directly from the sample placeholder > class, so I get: > > <?php > App::uses('Controller', 'Controller'); > > class AppController extends Controller { > $this->loadModel('Sitelist'); > } > > And then there's the licence part at the top and the "This is a > placeholder class" stuff in the middle, after App::uses(...). When I > get rid of the "$this->loadModel(...); line, it works, but that's the > default file because the only line I added was the loadModel line. > > The menu is a very simple list. In my template right now, I have the > list in a div like so: > > <div id="sitenavigation"> > <ul> > <li class="menuitem"><a href="link1here">Link 1 name</a></li> > <li class="menuitem"><a href="link2here">Link 2 name</a></li> > ... > </ul> > </div> > > My database just has a table that has the sitelist id, the name for > the link, and one more column for the link itself. > > I'd just like to be able to have the links get generated from the > database, where the href contents and the name part is taken from that > table. > > As a side note, is there any good component reference information for > 2.0.5? The stuff from the cookbook about creating components (http:// > book.cakephp.org/2.0/en/controllers/components.html) is a whopping 4 > lines long. The part from the 1.3 book (http://book.cakephp.org/1.3/ > view/996/Creating-Components) has a section on calling models from > components, but I'm too new at Cake to know if that would work, and it > says it's "not generally recommended". > > > Thanks! > > On Jan 20, 12:12 pm, Sam Sherlock <sam.sherl...@gmail.com> wrote: > > Is the load model call the line with the error? > > > > Can you post more code? > > > > The component idea should be fine. > > > > More details of your bab/menu model would be good. > > > > - S > > On 20 Jan 2012 16:13, "Dave D" <its.dave.daw...@gmail.com> wrote: > > > > > 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 sitehttp://ask.cakephp.organd help > > > others with their CakePHP related questions. > > > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com For more options, visit this > group > > > athttp://groups.google.com/group/cake-php > > -- > 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+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php