Re: Menu element
I've added this code to my app_controller and changed it to reflect my data model (my table is called "controls" instead of "categories"). Now I get the following errors on every page: Notice: Undefined property: AppController::$Control in /Library/ WebServer/Documents/serials/app/app_controller.php on line 48 Fatal error: Call to a member function generateList() on a non-object in /Library/WebServer/Documents/serials/app/app_controller.php on line 48 What am I missing? --~--~-~--~~~---~--~~ 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: Menu element
Thanks it is almost working now.. it works pretty much everywhere except for pages like home.thtml.. Also when there is an error it destriys the entire page and i don't see the messages anymore 0_o On Feb 19, 9:04 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > Well what i want accomplish is pretty easy, I have a table > > categories.. and i want to create links from the table categories in a > >menu. And thismenuhas to be on every page no matter what the url is. > > hmm, easiest thing would be to do this in the beforeFilter of your > app_controller. > > class AppController extends Controller > { > // you need access to the Category model > // nb: you will need to change this to match your Model name > var $uses = array('Category'); > > function beforeFilter () > { > $this->set ('menu_data', $this->Category->generateList ()); > } > > } > > hth > > jon > > -- > > jon bennett > t: +44 (0) 1225 341 039 w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
> Well what i want accomplish is pretty easy, I have a table > categories.. and i want to create links from the table categories in a > menu. And this menu has to be on every page no matter what the url is. hmm, easiest thing would be to do this in the beforeFilter of your app_controller. class AppController extends Controller { // you need access to the Category model // nb: you will need to change this to match your Model name var $uses = array('Category'); function beforeFilter () { $this->set ('menu_data', $this->Category->generateList ()); } } hth jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
Well what i want accomplish is pretty easy, I have a table categories.. and i want to create links from the table categories in a menu. And this menu has to be on every page no matter what the url is. On Feb 19, 8:31 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > Ah i see, but normally you would load the function of the controller > > through the url blog/post where index would be the function. But how > > can you load this function without having it in the url? > > I could think that maybe i can put it in the constructor of > > appcontroller but this would not be really good code i think, what if > > i wanted other things availalbe except the menu then i would need to > > put it all in the constructor, so is there any other way to do this ? > > I would perhaps put a default value in the constructor of app_controller > then a controller specific default in the constructor of each Controller > then amend this on a method-by-method basis as required. > > it really depends on what you're trying to accomplish and the > complexity of your app. > > jon > > -- > > jon bennett > t: +44 (0) 1225 341 039 w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
> Ah i see, but normally you would load the function of the controller > through the url blog/post where index would be the function. But how > can you load this function without having it in the url? > I could think that maybe i can put it in the constructor of > appcontroller but this would not be really good code i think, what if > i wanted other things availalbe except the menu then i would need to > put it all in the constructor, so is there any other way to do this ? I would perhaps put a default value in the constructor of app_controller then a controller specific default in the constructor of each Controller then amend this on a method-by-method basis as required. it really depends on what you're trying to accomplish and the complexity of your app. jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
Ah i see, but normally you would load the function of the controller through the url blog/post where index would be the function. But how can you load this function without having it in the url? I could think that maybe i can put it in the constructor of appcontroller but this would not be really good code i think, what if i wanted other things availalbe except the menu then i would need to put it all in the constructor, so is there any other way to do this ? On Feb 19, 5:39 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > Ok so i render it now in default.thtml so it is everywhere, does that > > mean that i must do the data handeling in app/app_controller.php > > yes, or in each controller if you want it to change. You could set a a > default value for the array in the app_controller, which you can then > override in your other controllers depending on what you want. > > hth > > jon > > -- > > jon bennett > t: +44 (0) 1225 341 039 w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
> Ok so i render it now in default.thtml so it is everywhere, does that > mean that i must do the data handeling in app/app_controller.php yes, or in each controller if you want it to change. You could set a a default value for the array in the app_controller, which you can then override in your other controllers depending on what you want. hth jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
Ok so i render it now in default.thtml so it is everywhere, does that mean that i must do the data handeling in app/app_controller.php On Feb 19, 5:11 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > Yes that i found but where should it get the array from ? > > ahh, ok. In your controller, you would do this: > > $menu_data = array('lorem','ipsum','etc'); > $this->set ('menu_data', $menu_data); > > then in your view you would do: > > echo $this->renderElement ('menu', array('data'=>$menu_data)); > > then, in your element you'd have something like: > > foreach ($data as $item): > ... > endforeach; > > hth > > jon > > -- > > jon bennett > t: +44 (0) 1225 341 039 w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
> Yes that i found but where should it get the array from ? ahh, ok. In your controller, you would do this: $menu_data = array('lorem','ipsum','etc'); $this->set ('menu_data', $menu_data); then in your view you would do: echo $this->renderElement ('menu', array('data'=>$menu_data)); then, in your element you'd have something like: foreach ($data as $item): ... endforeach; hth jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
Yes that i found but where should it get the array from ? On Feb 19, 4:17 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > Hi i am trying to make a menu, it renders fine in the default.thtml > > but how can i get data in the menu.thtml. Does it get's it's data from > > a component or a controller ? as i see that for example pagination is > > stored under app/pagination and not under controller or models ? > > I can't find anything about how to feed elements data from the db in > > the manuel :( > > echo $this->renderElement ('element_name',array('data'=>$viewvar)); > > hth > > jon > > -- > > jon bennett > t: +44 (0) 1225 341 039 w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Menu element
> Hi i am trying to make a menu, it renders fine in the default.thtml > but how can i get data in the menu.thtml. Does it get's it's data from > a component or a controller ? as i see that for example pagination is > stored under app/pagination and not under controller or models ? > I can't find anything about how to feed elements data from the db in > the manuel :( echo $this->renderElement ('element_name',array('data'=>$viewvar)); hth jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---