Properly setting up CacheHelper
Hi! I have a strange issue with CacheHelper and perhaps it's because I do some error in configuration. For the first time I encountered this problem while working on my main project. After it, I have downloaded CakePHP 2.2.4 and created an app for testing. As mentioned above I'm trying to use CacheHelper. What I did: New CakePHP 2.2.4, freshly downloaded. No changes was made except of: *core.php:* I added Configure::write('Cache.check', true); as mentioned in the Cookbook *bootstrap.php:* (It was already there, so I did not make any changes.) Configure::write('Dispatcher.filters', array( 'AssetDispatcher', 'CacheDispatcher' )); *Controller/NewsController.php* – this is my controller for testing. ?php class NewsController extends AppController { public $helpers = array('Cache'); public $cacheAction = array( 'view' = 36000, 'index' = 48000 ); public function index() { } public function clear() { clearCache(); } } *View/News/index.ctp*: Things went OK! What happened On the first page load (domain.com/news) I can see my view rendered as expected. If I try to access page for the second time I get the error: Error: Class 'AppController' not found File: ../app/Controller/NewsController.php Line: 2 And as long as I did not clear the cache, I get the same error. After clearing cache I can once again load page and after that everything is repeated and I get the same error. Thanks in advance. -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: Properly setting up CacheHelper
Thank you, Mark. It solves the problem, but I was absolutely sure that it is enough to specify `App::uses('AppController', 'Controller');` in the /Controller/AppController.php I think they should definitely add the importance of inclusion of this fragment of code in the Cookbook. On Wednesday, December 26, 2012 7:08:24 PM UTC+4, euromark wrote: thats because you forgot a vital part above your class NewsController extends AppController {} above it add `App::uses('AppController', 'Controller');` It is important that you always specify all used classes in your files at the top. Am Mittwoch, 26. Dezember 2012 16:00:40 UTC+1 schrieb Nvp: Hi! I have a strange issue with CacheHelper and perhaps it's because I do some error in configuration. For the first time I encountered this problem while working on my main project. After it, I have downloaded CakePHP 2.2.4 and created an app for testing. As mentioned above I'm trying to use CacheHelper. What I did: New CakePHP 2.2.4, freshly downloaded. No changes was made except of: *core.php:* I added Configure::write('Cache.check', true); as mentioned in the Cookbook *bootstrap.php:* (It was already there, so I did not make any changes.) Configure::write('Dispatcher.filters', array( 'AssetDispatcher', 'CacheDispatcher' )); *Controller/NewsController.php* – this is my controller for testing. ?php class NewsController extends AppController { public $helpers = array('Cache'); public $cacheAction = array( 'view' = 36000, 'index' = 48000 ); public function index() { } public function clear() { clearCache(); } } *View/News/index.ctp*: Things went OK! What happened On the first page load (domain.com/news) I can see my view rendered as expected. If I try to access page for the second time I get the error: Error: Class 'AppController' not found File: ../app/Controller/NewsController.php Line: 2 And as long as I did not clear the cache, I get the same error. After clearing cache I can once again load page and after that everything is repeated and I get the same error. Thanks in advance. -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: Properly setting up CacheHelper
Thank you. Your answer was very helpful to me. On Wednesday, December 26, 2012 10:39:18 PM UTC+4, euromark wrote: as I stated above, it is vital that you always include all uses classes throughout your files. so, no. it is not enough - as you just experienced yourself. it might work up to some point - and than it breaks. the App::uses can be compared to require statements. If you don't tell cake what files are required it fill fail eventually. same goes for helpers, models, behaviors, ... Am Mittwoch, 26. Dezember 2012 16:18:55 UTC+1 schrieb Nvp: Thank you, Mark. It solves the problem, but I was absolutely sure that it is enough to specify `App::uses('AppController', 'Controller');` in the /Controller/AppController.php I think they should definitely add the importance of inclusion of this fragment of code in the Cookbook. On Wednesday, December 26, 2012 7:08:24 PM UTC+4, euromark wrote: thats because you forgot a vital part above your class NewsController extends AppController {} above it add `App::uses('AppController', 'Controller');` It is important that you always specify all used classes in your files at the top. Am Mittwoch, 26. Dezember 2012 16:00:40 UTC+1 schrieb Nvp: Hi! I have a strange issue with CacheHelper and perhaps it's because I do some error in configuration. For the first time I encountered this problem while working on my main project. After it, I have downloaded CakePHP 2.2.4 and created an app for testing. As mentioned above I'm trying to use CacheHelper. What I did: New CakePHP 2.2.4, freshly downloaded. No changes was made except of: *core.php:* I added Configure::write('Cache.check', true); as mentioned in the Cookbook *bootstrap.php:* (It was already there, so I did not make any changes.) Configure::write('Dispatcher.filters', array( 'AssetDispatcher', 'CacheDispatcher' )); *Controller/NewsController.php* – this is my controller for testing. ?php class NewsController extends AppController { public $helpers = array('Cache'); public $cacheAction = array( 'view' = 36000, 'index' = 48000 ); public function index() { } public function clear() { clearCache(); } } *View/News/index.ctp*: Things went OK! What happened On the first page load (domain.com/news) I can see my view rendered as expected. If I try to access page for the second time I get the error: Error: Class 'AppController' not found File: ../app/Controller/NewsController.php Line: 2 And as long as I did not clear the cache, I get the same error. After clearing cache I can once again load page and after that everything is repeated and I get the same error. Thanks in advance. -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
How to pass HABTM validation errors to FormHelper?
Hi! I read many topics about HABTM validation in Cake but I can't figure out how to solve my problem. I have my main model – Restaurants, it has many HABTM relations to additional models. Now I'm building admin area, and I'm working with new controller in which I have public $uses = array('Restaurant'); This admin area controller have an edit action: ... else { if ($this-Restaurant-save($this-request-data)) { $this-Session-setFlash('Ok!'); $this-redirect(array('action' = 'edit', $id)); } else { $this-Session-setFlash('Error'); $this-redirect(array('action' = 'edit', $id)); } } In my Restaurant model I have: function beforeValidate() { foreach($this-hasAndBelongsToMany as $k=$v) { if(isset($this-data[$k][$k])) { $this-data[$this-alias][$k] = $this-data[$k][$k]; } } } I can't comment this code because it's from HABTM validation guide. And also in Restaurant model I have some validation rules: var $validate = array( 'engcompanyname' = array( 'rule' = 'notEmpty', 'message' = 'Test message' ) ); In edit.ctp I have standard form builded with FormHelper: ?php echo $this-Form-create(); ... echo $this-Form-input('engcompanyname', array('label' = 'Test label')); ... echo $this-Form-end(array('label' = 'Save'); ? The problem is that validation itself works very well, I got my session message back for success and error conditions, the data from the form correctly passes to database etc. But FormHelper does not show any error messages. CakePHP version is 2.2.2 Thanks in advance! -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: hasMany through - how to retrieve my data?
I also tried HABTM with the same result, I can't retrieve the data that I need. But as fas as I know there is no big difference between hasMany through (Join Model) and HABTM. I'll be glad if you help me correctly retrieve my data with conditions I posted in the first message, no matter if you choose HABTM or Join Model (I know how to setup both of them). On Monday, September 17, 2012 6:35:18 AM UTC+4, jsundquist wrote: Why are you using a hasMany instead of a hasAndBelongsToMany? You wouldn't need the id column as you two ideas together would be your index. - The cold winds are rising On Sep 16, 2012 5:17 PM, Nvp leh...@gmail.com javascript: wrote: Hi! I built DB with tables: *restaurants* - main table *kitchens* - second table *kitchen_restaurants* - join table with fields: id, kitchen_id, restaurant_id *Model/Restaurant.php*: public $hasMany = array( 'KitchenRestaurant' ); *Model/Kitchen.php*: public $hasMany = array( 'KitchenRestaurant' ); *Model/KitchenRestaurant.php*: public $belongsTo = array( 'Restaurant', 'Kitchen' ); The problem is that I have separate controller for my main page in which I need to retrieve data from this models with complex conditions. I added public $uses = array('Restaurant'); to my main page controller and here comes the part where I need your advices. I need to select only those restaurants where kitchen = $id. I've tried to add public function index() { $this-set('rests', $this-Restaurant-find('all', array( 'conditions' = array('Restaurant.active' = 1, 'KitchenRestaurant.id' = 1) ))); } but I get Column not found error. How to properly retrieve data in hasMany through or HABTM? Thanks! -- Like Us on FacekBook 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 post to this group, send email to cake...@googlegroups.comjavascript: . To unsubscribe from this group, send email to cake-php+u...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
hasMany through - how to retrieve my data?
Hi! I built DB with tables: *restaurants* - main table *kitchens* - second table *kitchen_restaurants* - join table with fields: id, kitchen_id, restaurant_id *Model/Restaurant.php*: public $hasMany = array( 'KitchenRestaurant' ); *Model/Kitchen.php*: public $hasMany = array( 'KitchenRestaurant' ); *Model/KitchenRestaurant.php*: public $belongsTo = array( 'Restaurant', 'Kitchen' ); The problem is that I have separate controller for my main page in which I need to retrieve data from this models with complex conditions. I added public $uses = array('Restaurant'); to my main page controller and here comes the part where I need your advices. I need to select only those restaurants where kitchen = $id. I've tried to add public function index() { $this-set('rests', $this-Restaurant-find('all', array( 'conditions' = array('Restaurant.active' = 1, 'KitchenRestaurant.id' = 1) ))); } but I get Column not found error. How to properly retrieve data in hasMany through or HABTM? Thanks! -- Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
How to show latest comments (sitewide)?
Hi! I need to have a sitewide sidebar which will contain 5 latest comments to articles. Should I use elements with requestAction + cache in default layout or it can be achieved in more simple way? I use CakePHP 2.2.1. Thanks. -- 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. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Re: How to show latest comments (sitewide)?
I'm new to CakePHP, can you please provide me some example or expand the idea? On Thursday, August 16, 2012 11:27:38 PM UTC+4, ibejohn818 wrote: Get and Set the data in your app_controller On Aug 16, 2012, at 12:12 PM, Nvp wrote: Hi! I need to have a sitewide sidebar which will contain 5 latest comments to articles. Should I use elements with requestAction + cache in default layout or it can be achieved in more simple way? I use CakePHP 2.2.1. Thanks. -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake...@googlegroups.comjavascript: . To unsubscribe from this group, send email to cake-php+u...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php?hl=en-US. -- 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. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
$title_for_layout and what changes I need to do
Hi! It's my first Cake project I have about 5-6 static pages they are served by the default PagesController. I have title ?php echo $title_for_layout ? /title in my layout file and ?php $this-set('title_for_layout', 'Page Title'); ? in my views files. So as I read on API page $title_for_layout is deprecated and will be removed in CakePHP 3.0, and I should use title_for_layout instead. But I don't understand how and what changes I should do in my layout/view files. Can anyone provide me an example please? Thanks. -- 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php