yes you can use model's methods in controller, but not controller's methods in model...if you want to use same logic in a lot of models, then use behaviors...:) :) -- Lep pozdrav, Tilen Majerle http://majerle.eu
2011/3/9 Jeremy Burns | Class Outfit <[email protected]> > Really? Maybe I am showing my ignorance here, but can you access a model's > controller functions from within the model? > > Jeremy Burns > *Class Outfit* > * > * > [email protected] <[email protected]> > http://www.classoutfit.com > > On 9 Mar 2011, at 14:55, Krissy Masters wrote: > > If the controller is related thru Model relations then you can chain them > like > $this->User->Gallery->Image > > You can access any user / gallery / image controllers action thru the chain > > Or if not related use Telen’s loadModel. > > K > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Tilen Majerle > *Sent:* Wednesday, March 09, 2011 10:52 AM > *To:* [email protected] > *Cc:* Carachi > *Subject:* Re: constructClasses() ???? > > but, i really don't know why u use other controller in some controller... > ...if you want same logic in both controllers, then use components (in > controller) / helpers (in views), if you need to connect with other database > table, then use $this->loadModel('ModelName'); in controller to load some > model to work with it... > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2011/3/9 Tilen Majerle <[email protected]> > it's not __constructor() but __construct() > beforeFilter() callback is called AFTER __construct, but try this (in > AppController, or anyone else you want), maybe works if i understand u good, > so: > > class SomeController extends AppController //or extends Controller if you > work in AppController > { > function __construct() > { > parent::__construct(); > //then here $controller =& new Some2Controller(); and > $controller->constructClasses() ///maybe works....idk... > } > } > > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2011/3/9 Carachi <[email protected]> > > > Thank you Tilen > I want to set some global variable because I use this a lot of time in > the controller. > So when controller is builds I prefer set this value and use it. > In php I use __constructor() but in cake? > Is right use beforeFilter() like constructor? > > When I want use a controller from an other controller I write: > $Controller1 = new Controller1Controller; > $Controller1->constructClasses(); > $Controller1->myFunction(); > > Why I can't set constructClasses() in the Controller1 ?? > > Thank you > > > > On Mar 9, 2:53 pm, Tilen Majerle <[email protected]> wrote: > > why you want to do that, i'm sure you can do this in other way...:) > > -- > > Lep pozdrav, Tilen Majerlehttp://majerle.eu > > > > 2011/3/9 Carachi <[email protected]> > > > > > > > > > > > > > > > > > If I want set some parameter in the construct class, how can I do?? > > > > > On Mar 9, 2:12 pm, Jeremy Burns | Class Outfit > > > <[email protected]> wrote: > > > > Try putting it in beforeFilter() instead (and don't forget to include > > > parent::beforeFilter() too). > > > > > > Jeremy Burns > > > > Class Outfit > > > > > > [email protected]http://www.classoutfit.com > > > > > > On 9 Mar 2011, at 13:02, Carachi wrote: > > > > > > > Hi, > > > > > I have this problem. > > > > > I want use a construct for a my controller so I insert in this > > > > > controller this function: > > > > > > > var $user; > > > > > public function constructClasses(){ > > > > > $this->user = 'test'; > > > > > } > > > > > > > but it return this error: > > > > > Fatal error: Call to undefined method stdClass::allow() in > /home/www/ > > > > > app/controllers/inizialization_controller.php on line 15 > > > > > > > I also try in php way with __constructor() but doesn't works > > > > > > > Why?? > > > > > Thank you > > > > > > > Bye > > > > > > > -- > > > > > Our newest site for the community: CakePHP Video Tutorialshttp:// > > > tv.cakephp.org > > > > > Check out the new CakePHP Questions > sitehttp://ask.cakephp.organdhelp > > > others with their CakePHP related questions. > > > > > > > To unsubscribe from this group, send email to > > > > > [email protected] 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 sitehttp://ask.cakephp.organd help > > > others with their CakePHP related questions. > > > > > To unsubscribe from this group, send email to > > > [email protected] 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 > [email protected] 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 > [email protected] 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 > [email protected] 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 > [email protected] 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
