How to specify layout once
So I have admin functions in my controller. I can change the layout used by doing: $this-layout = 'admin'; But instead of adding that line in for each of my admin actions I was wondering if there was a way to do it just once. Mark --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: For basic page_controller what is the typical setup
Ok so make my own dynamic page controller. So how about if I want the urls to be: Domain.com/home Domain.com/about Domain.com/projects Etc ... So would I create specific methods in my controller for each of those: e.g. function home() { } function about() { } function projects() { } Thanks, Mark -Original Message- From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Sunday, February 04, 2007 4:33 PM To: Cake PHP Subject: Re: For basic page_controller what is the typical setup cake's pages controller is meant for static pages. for dynamic pages, i would create a new controller, along with a model. Although you could override the pagescontroller to extend it's functionality offcourse. And i think the using elements for menus is a good idea, i do it too. Although you must be careful: if the element is called in the layout, it will _always_ be shown when the default layout is used (hence: probably for each section on your site) so you must be sure the $menu variable is always set. The home action is not the right place for that. AppController's beforeRender function is a good place to do that. You could even put the $this-requestAction('/menus/getMenus') right in the menu element. It's very easy and many people do it like that --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help with associations and scaffolding
So I have a cookbook application with recipes and categories: Recipes id:title:recipe:created_on:category_id Categories id:name I am trying to use bake to setup the associations between the categories and recipes: CATEGORY MODEL class Category extends AppModel { var $name = 'Category'; //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasMany = array( 'Recipe' = array('className' = 'Recipe', 'foreignKey' = 'category_id', 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'dependent' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), ); } RECIPE MODEL class Recipe extends AppModel { var $name = 'Recipe'; //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasOne = array( 'Category' = array('className' = 'Category', 'foreignKey' = 'id', 'conditions' = '', 'fields' = '', 'order' = '', 'dependent' = '' ), ); } Do I have the concept or am I missing something? I also had bake setup the controllers and views for me. When I view a recipe say with category_id = 2, category 1 shows up under views. Also should the add/edit view generated by scaffold have the categories as a select box with the categories in it? Right now I have a text box which makes me think that I don't have the associates set up correctly. Thanks Mark --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---