Hi TWIOF,
Before I say anything further: I'm just stating my opinions and if you
are happy with the way it was working before skip to "cheers" :)
My mistake. Despite being quite familiary with requestAction I still
mix up the 2 syntaxes.
If you move your listing function to the model, you then eliminate
completely the need/desire to use requestAction. In this way there is
absolutely no repetition of code to do the same thing in several
places. If some logic need to be determined by the controller, define
the model method to expect parameters, but put as little logic as
possible in your controller.
Whether the call to the model method is in the (app) controller or in a
component is down effectively to the personal preference, and
complexity. For the example code below I'd put it in the app
controller; if it starts looking a bit unweildy or spawns a couple of
sub methods a component then becomes the more obvious choice.
If you are looking for a simple explenation on how to implement this
model method, just make this code work:
beforeRender() {
$listing = new Listing;
$Switch; // Determin this var or pass $this->name or something similar
etc.
$stuff = $listing->tonight($Switch); // <- create this method in your
model
$this->set("TonightsListings",$stuff);
.. etc..
}
HTH, Cheers,
AD7six
PS. For the benefit of anyone unaware: You don“t normally instanciate
model instances yourself as it's not necessary you would put var $uses
= array(X,Y,Z); in the controller. However I avoided this because if
you set it in your app controller, you would then lose the automatic
"ThingiesController" uses the model "Thingy" functionality.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---