Re: Is this EVIL in cake?
Thank you, the modelClass solution is perfect Long life to AD7six. On 4 Nov, 09:09, AD7six wrote: > On 4 nov, 09:02, "lacenaepro...@gmail.com" > wrote: > > > > > > > OK, I don't know if it is the same to import and use the model or to > > use the default model of the controller. > > > In the action I save the model like this: > > > $this->Group->Save > > > So in the component I'd like to set the locale just before the save. I > > would put the code in the initialize callback of the component: > > > > > $this->controller->[...access the group model somehow...]->locale = > > the_new_locale; > > > > > Sorry, but I don't know if this is the same of importing the model and > > use it. Pheraps the right question is: > > > Does '$this->Group' works on an INSTANCE or on the CLASS?? > > > Answer this question, and I will be a happy man. > > > THANKS!! > > try > > $this->controller->{$this->controller->modelClass}->locale = > 'lowercase'; > > OR > > ClassRegistry::init('ThisModel')->locale = 'lowercase'; > > Depending on if you want the controller's model irrespective of what > it is, or a specific model that may or may not be attached to the > controller. > > hth, > > AD- Nascondi testo citato > > - Mostra testo citato - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
On 4 nov, 09:02, "lacenaepro...@gmail.com" wrote: > OK, I don't know if it is the same to import and use the model or to > use the default model of the controller. > > In the action I save the model like this: > > $this->Group->Save > > So in the component I'd like to set the locale just before the save. I > would put the code in the initialize callback of the component: > > > $this->controller->[...access the group model somehow...]->locale = > the_new_locale; > > > Sorry, but I don't know if this is the same of importing the model and > use it. Pheraps the right question is: > > Does '$this->Group' works on an INSTANCE or on the CLASS?? > > Answer this question, and I will be a happy man. > > THANKS!! try $this->controller->{$this->controller->modelClass}->locale = 'lowercase'; OR ClassRegistry::init('ThisModel')->locale = 'lowercase'; Depending on if you want the controller's model irrespective of what it is, or a specific model that may or may not be attached to the controller. hth, AD --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
OK, I don't know if it is the same to import and use the model or to use the default model of the controller. In the action I save the model like this: $this->Group->Save So in the component I'd like to set the locale just before the save. I would put the code in the initialize callback of the component: $this->controller->[...access the group model somehow...]->locale = the_new_locale; Sorry, but I don't know if this is the same of importing the model and use it. Pheraps the right question is: Does '$this->Group' works on an INSTANCE or on the CLASS?? Answer this question, and I will be a happy man. THANKS!! On 4 Nov, 01:45, Amit wrote: > http://filchiprogrammer.wordpress.com/2008/08/27/followthemanual/ > > On Nov 3, 4:32 pm, AD7six wrote: > > > > > On 3 nov, 23:00, "lacenaepro...@gmail.com" > > wrote: > > > > Thanks for the replies but nowHOW CAN I ACCESS THE MODEL FROM > > > WITHIN THE COMPONENT? > > > you seem to have accidentally written most of your message(s) in > > capital letters.- Nascondi testo citato > > - Mostra testo citato - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
On 3 nov, 23:00, "lacenaepro...@gmail.com" wrote: > Thanks for the replies but nowHOW CAN I ACCESS THE MODEL FROM > WITHIN THE COMPONENT? you seem to have accidentally written most of your message(s) in capital letters. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
Thanks for the replies but nowHOW CAN I ACCESS THE MODEL FROM WITHIN THE COMPONENT? Dario On 3 Nov, 18:35, Miles J wrote: > Or you could just do it in the AppController::beforeFilter(). > > On Nov 3, 7:52 am, "euromark (munich)" > wrote: > > > > > there are some components that work that way > > its not really evil... > > in some cases this would be the appropriate way actually > > > On 3 Nov., 14:47, "lacenaepro...@gmail.com" > > wrote: > > > > SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!! > > > > HI, > > > > I'm building a component that automatically sets the locale data > > > member of a translate behaviour. > > > > In the action I look for the lang param, then call the component > > > method. > > > > I'd like the component to set the locale data member in order to > > > avoid > > > to do that in ANY action. > > > > Something like that: > > > > // --- component class > > > function initialize(&controller, .) { > > > // HERE I SAVE THE CONTROLLER INSTANCE > > > $this->controller = $controller; > > > > > > > } > > > > function doSomething() { > > > // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE > > > $mod = $this->controller->. > > > $model->locale = $mySavedLocale; > > > > } > > > > IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD? > > > > THANKS!! > > > > On 3 Nov, 14:44, "lacenaepro...@gmail.com" > > > wrote: > > > > > HI, > > > > > I'm building a component that automatically sets the locale data > > > > member of a translate behaviour. > > > > > In the action I look for the lang param, then call the component > > > > method. > > > > > I'd like the component to set the locale data member in order to avoid > > > > to do that in ANY action. > > > > > Something like that: > > > > > // --- component class > > > > function initialize(&controller, .) { > > > > // HERE I SAVE THE CONTROLLER INSTANCE > > > > $this->controller = $controller; > > > > > > > > > } > > > > > function doSomething() { > > > > > }- Nascondi testo citato > > > > > - Mostra testo citato -- Nascondi testo citato > > - Mostra testo citato - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
Or you could just do it in the AppController::beforeFilter(). On Nov 3, 7:52 am, "euromark (munich)" wrote: > there are some components that work that way > its not really evil... > in some cases this would be the appropriate way actually > > On 3 Nov., 14:47, "lacenaepro...@gmail.com" > wrote: > > > SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!! > > > HI, > > > I'm building a component that automatically sets the locale data > > member of a translate behaviour. > > > In the action I look for the lang param, then call the component > > method. > > > I'd like the component to set the locale data member in order to > > avoid > > to do that in ANY action. > > > Something like that: > > > // --- component class > > function initialize(&controller, .) { > > // HERE I SAVE THE CONTROLLER INSTANCE > > $this->controller = $controller; > > > > > } > > > function doSomething() { > > // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE > > $mod = $this->controller->. > > $model->locale = $mySavedLocale; > > > } > > > IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD? > > > THANKS!! > > > On 3 Nov, 14:44, "lacenaepro...@gmail.com" > > wrote: > > > > HI, > > > > I'm building a component that automatically sets the locale data > > > member of a translate behaviour. > > > > In the action I look for the lang param, then call the component > > > method. > > > > I'd like the component to set the locale data member in order to avoid > > > to do that in ANY action. > > > > Something like that: > > > > // --- component class > > > function initialize(&controller, .) { > > > // HERE I SAVE THE CONTROLLER INSTANCE > > > $this->controller = $controller; > > > > > > > } > > > > function doSomething() { > > > > }- Nascondi testo citato > > > > - Mostra testo citato - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
http://filchiprogrammer.wordpress.com/2008/08/27/followthemanual/ On Nov 3, 4:32 pm, AD7six wrote: > On 3 nov, 23:00, "lacenaepro...@gmail.com" > wrote: > > > Thanks for the replies but nowHOW CAN I ACCESS THE MODEL FROM > > WITHIN THE COMPONENT? > > you seem to have accidentally written most of your message(s) in > capital letters. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
there are some components that work that way its not really evil... in some cases this would be the appropriate way actually On 3 Nov., 14:47, "lacenaepro...@gmail.com" wrote: > SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!! > > HI, > > I'm building a component that automatically sets the locale data > member of a translate behaviour. > > In the action I look for the lang param, then call the component > method. > > I'd like the component to set the locale data member in order to > avoid > to do that in ANY action. > > Something like that: > > // --- component class > function initialize(&controller, .) { > // HERE I SAVE THE CONTROLLER INSTANCE > $this->controller = $controller; > > > } > > function doSomething() { > // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE > $mod = $this->controller->. > $model->locale = $mySavedLocale; > > } > > IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD? > > THANKS!! > > On 3 Nov, 14:44, "lacenaepro...@gmail.com" > wrote: > > > HI, > > > I'm building a component that automatically sets the locale data > > member of a translate behaviour. > > > In the action I look for the lang param, then call the component > > method. > > > I'd like the component to set the locale data member in order to avoid > > to do that in ANY action. > > > Something like that: > > > // --- component class > > function initialize(&controller, .) { > > // HERE I SAVE THE CONTROLLER INSTANCE > > $this->controller = $controller; > > > > > } > > > function doSomething() { > > > }- Nascondi testo citato > > > - Mostra testo citato - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Is this EVIL in cake?
SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!! HI, I'm building a component that automatically sets the locale data member of a translate behaviour. In the action I look for the lang param, then call the component method. I'd like the component to set the locale data member in order to avoid to do that in ANY action. Something like that: // --- component class function initialize(&controller, .) { // HERE I SAVE THE CONTROLLER INSTANCE $this->controller = $controller; } function doSomething() { // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE $mod = $this->controller->. $model->locale = $mySavedLocale; } IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD? THANKS!! On 3 Nov, 14:44, "lacenaepro...@gmail.com" wrote: > HI, > > I'm building a component that automatically sets the locale data > member of a translate behaviour. > > In the action I look for the lang param, then call the component > method. > > I'd like the component to set the locale data member in order to avoid > to do that in ANY action. > > Something like that: > > // --- component class > function initialize(&controller, .) { > // HERE I SAVE THE CONTROLLER INSTANCE > $this->controller = $controller; > > > } > > function doSomething() { > > > > }- Nascondi testo citato > > - Mostra testo citato - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---