On Mon, Feb 2, 2009 at 2:45 PM, Chris Mc <cmcclel...@yahoo.com.au> wrote: > > Mate, it's not you it's me ..... I'm simply guessing at what's working > here to get my app to work. I just assumed that I could get some data > on the homepage by using that file because that file renders the > homepage screen. If there's something wrong with that, it's my lack > of understanding about how Cake works. I have been searching for > several hours to figure out how to do this (including posting on > forums) and you are the only one that has shown enough knowledge and > helpfulness (is that a word?) to reply.
It is a word, though I don't know how much help I can be, because what comes next is liable to confuse you even more ;-) The way I usually do things is to have PagesController take care of the main site "homepage", as well as some other "static" pages. To do this, I copied pages_controller.php from the cake/libs dir to app/controllers. Then, I create a view, 'home.ctp', under views/pages. The route for that is: Router::connect( '/', array( 'controller' => 'pages', 'action' => 'display', 'home' ) ); http://bakery.cakephp.org/articles/view/taking-advantage-of-the-pages-controller As for using a view at views/index.ctp, I've never done that. It's still PagesController that's dealing with that, though. But that's not really the issue here. > >> You should begin with linking a route to a controller, then deal with >> the view for that action. I suspect that what you're trying to do is >> to access the RestaurantsController from a PagesController view. This >> is what requestAction() is for, though it's generally a good idea to >> avoid using it. There are other ways. For one thing, it sems like this >> table should be an element. >> >> What is the route you're using to fetch this page? And what's the URL? >> Is there some other controller involved? > > It's all locally developed on my machine so far, so the link is > http://localhost/mysite/ and at that URL I see the /views/index.ctp > rendered properly. Sorry, I meant just the path part of the URL, not that I wanted to see the page myself. OK, so this view is the result of the '/' route and PagesController is handling the request. BTW, you've got the "mysite" bit in the path. Cake can obviously deal with that, but it's not something I do--I always create a separate virtual host for each site, so that my main page is at '/', not '/name_of_site/'. That might lead to some issues when you put this website live. I wouldn't be too concerned about it just yet, though. It's just something to keep in mind. > > Remember, I'm very new to this .... I'm trying to learn based on what > I want my project to do and using code that (usually) I'm copying from > a known source that works. My advice would be to take things one step at a time. Get your homepage working without this table first. Then, create a view at 'views/restaurants/index.ctp' (if the controller is named RestaurantsController and the action/method is 'index') and make sure you're able to actually find and display the data you want. If you don't require pagination, don't use it. And, in any case, make sure find() works, first. Finally, if you want to include this table in your main homepage, you can use requestAction() but you should understand the implications of doing so--it'll adversely affect performance because it'll create an entirely new request, causing Cake to load a whole bunch of stuff twice. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com 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?hl=en -~----------~----~----~----~------~----~------~--~---