$this -> render() not using correct view
Collection controller, want to use the same view file (display_collection) to display the multiple types of collections. Very basic, no plugins involved. Pretty much like straight out of the book. Problem is that the default view for the action is being rendered. public function CollectionOne() { $this -> render = ('/Collection/display_collection'); } Does not use display_collection.ctp, it uses collection_one.ctp (more specifically, it complains about collection_one.ctp missing) Is there a little trick to render()? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Certain models via $uses cause non-object errors in Controller
Well, I figured it out. :: facepalm:: Typos are fail. :| On Monday, December 9, 2013 6:55:37 PM UTC-6, Kristen M wrote: > > > I need to include a couple of models in various controllers. However, when > I try to put the models in $uses() they invariably throw non-object errors > even when not being called, and even when the model is totally empty. > > However, ONE model ("User") will play nice. > > There are no relationships between any of these models. > > For example, in the Item Model/Controller: > > $uses = array("User") > > Does not throw any sort of errors and the pages behave normally. > > However: > > $uses = array("Trinket"); > > Throws a non-object error, even when Trinket is not being used and I'm > using the Item model. Even if I completely empty Trinket I still get a non > object error. Every other model causes this error EXCEPT User, but if I use > a duplicate of User and just rename it Trinket, Novel, Candy, whatever, it > throws the error. There is nothing special about User except its name that > I can see. > > What am I missing? > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Certain models via $uses cause non-object errors in Controller
I need to include a couple of models in various controllers. However, when I try to put the models in $uses() they invariably throw non-object errors even when not being called, and even when the model is totally empty. However, ONE model ("User") will play nice. There are no relationships between any of these models. For example, in the Item Model/Controller: $uses = array("User") Does not throw any sort of errors and the pages behave normally. However: $uses = array("Trinket"); Throws a non-object error, even when Trinket is not being used and I'm using the Item model. Even if I completely empty Trinket I still get a non object error. Every other model causes this error EXCEPT User, but if I use a duplicate of User and just rename it Trinket, Novel, Candy, whatever, it throws the error. There is nothing special about User except its name that I can see. What am I missing? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
JOIN in belongsTo (but not HABTM)
Is this possible? Situation: Users have many Items I want to pull a User's total inventory, which sits in the inventory table. But I also need to pull some fields from the master item table (like item name) or to be able to pull items only be their type (this data sits in the master table) Is it possible in a belongsTo relationship to do a join that involves joining on a key that isn't the foreign key used in the belongsTo relationship? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Multiple Models In A Controller
Here is a code snippet. The Banking Model is needed in the Rename() method. It's actually needed in multiple other methods that aren't posted here. App::uses('Banking'...) is commented out, but it does nothing when it's not. The only thing that works is the loadModel() call in the method. request -> is("post")) { $this -> loadModel("Banking"); $player_money = $this -> Banking -> findByUserId($user_ID); $transaction_flag = $this -> Banking -> VerifyFunds(array("player_details" => $user_balance, "silver_cost" => 20)); } } } ?> On Sunday, November 17, 2013 4:42:02 AM UTC-6, John Andersen wrote: > > Hi Kristen M > > Please ensure that you are using the correct model name; ensure that the > model filename is correct, etc. > > Also show us the code for Uses including the statements before and after > the Uses statements. > > What error message are you receiving when using Uses? > > Kind regards > John > > On Saturday, 16 November 2013 19:21:04 UTC+2, Kristen M wrote: >> >> There are several ways to do this, but in my application, only one seems >> to work. >> >> $this -> loadModel("Model"); >> >> From my reading it seems there are an assortment of ways to include a >> Model that doesn't require re-loading a Model everytime I need it (assuming >> I need it multiple times within a controller) But in my code App::Uses and >> the $uses = array() do not work- they throw errors. >> >> So I'm clearly missing some small little detail. Could someone point it >> out to me? >> > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Multiple Models In A Controller
There are several ways to do this, but in my application, only one seems to work. $this -> loadModel("Model"); >From my reading it seems there are an assortment of ways to include a Model that doesn't require re-loading a Model everytime I need it (assuming I need it multiple times within a controller) But in my code App::Uses and the $uses = array() do not work- they throw errors. So I'm clearly missing some small little detail. Could someone point it out to me? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Best Practice Question - Components
Yeah, the point of the exercise is to do things the "Cake Way" and take advantage of all things automagical and Cake. ;) After puzzling over the docs for a bit and realizing it's not bad form to have a controller use multiple models, I decided that splitting the existing classes into a model and a component was probably the "correct" solution. The model handles all the data, while the component contains common functions all controllers that use the model will need, like calculations and verification of amounts. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Best Practice Question - Components
I'm not a new programmer (I'd say advanced beginner/intermediate) but I'm quite new to Cake and MVC in general. I've decided best way to learn CakePHP and MVC is to take an existing (functional, live) project and port it to Cake for kicks. Get the grand tour of all the basics. In my existing project I have a number of utility classes that are used by the other classes. 2 of them are an Item class and a Banking class. Item obviously contains all the information about a user's inventory, plus handles updating/deducting items, as well as using items. Banking does just that- tracks a user's currency and handles transactions. Banking is used between the Shop systems, Item is used by Shop and various action classes. So I need a way to share their functionality between all the various other controllers that require them. Simple example would be the user wants to buy an item from the shop, have to verify the item is in stock, the item's price, that the player has the currency to pay for it, deliver the item, deduct the payment and deduct the item from shop inventory. While a different Controller (say, Toll Bridge) needs the Banking functions to verify the user has the funds to pay the toll, then debit the transaction. It SOUNDS like what I need to do is to create Banking & Item Components, then the other controllers can make use of them as needed. However, this would also require including various queries to chat with the database. The CakePHP example on Components only shows a simple math operation with passed params, and says nothing about if using Components as little "bundles" of functionality that involve their own validations and database interactions (although this is strongly implied) There is some conversation on the 'net that what actually needs to happen is Banking and Item should be controllers, and they get imported as needed. What's the best way to go about this? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.