Re: try/catch action
As far as I remember, you don't need to do try catch, just compare the current action against the actions defined in the controller. For example you can do the following (quick and dirty solution) in the AppController beforeFilter method: [code] if (!in_array($this-params['action'], get_class_methods($this))) { do your error processing } [/code] or even better, you can try to make your own cakeError processing. See: http://book.cakephp.org/view/154/Error-Handling Enjoy, John On Mar 24, 6:43 am, Josh joshs.silver...@gmail.com wrote: Hello I would like to somehow apply a try catch statement to all Actions as a backstop for any uncaught exceptions. I think this would be particularly helpful for Ajax Actions, because the catch statement could send back a default 4xx status code. Prototype's onFailure() function could then do the client-side error handling. How can I do this without wrapping the Action call with a try/catch in the cake dispatcher ($controller-dispatchMethod($params['action'], $params['pass']);) Does anybody have a suggestion or another workable strategy for gaining this functionality? Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: repeatedly call controller action through ajax
I am not sure how your page loading is working - with ajax or without - so here is what I would do based on your information: In the first ajax call to the bar action, retrieve the dynamic condition and return it together with the ajax result. Then act upon it as you want. Enjoy, John On Mar 24, 1:22 am, alex bailey v...@planet-generals.de wrote: Hi guys, I'm having a problem with my project where I could freak out about. The situation is the following: I have a controller foo which has an action bar. Now the thing i want to get going: have the bar action running all the time while your on the page by a fixed interval with a condition if a certain entry is made in the database. I got it to work by using ajax and the remoteTimer method. But now I have the following problem: I can't figure out how I can have a dynamic condition like: Only run the ajax event if a certain field in database is set to 0 or 1 I know I can control the execution by the condition param and using a javascript If() (Like: 'condition' = '10 == 90' which will prevent it from running) in there but is it possible to populate this condition dynamically from the database or is there even a better way to handle this whole situation? Big thanks in advance. Regards Alex Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Data validation rule (between) never returns true
most auth setups also have a password_confirm field and use that to validate password length etc. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Weird Validation Question
I agree 2 emails is confusing. Then you should rethink your choice, it's not just confusing but limiting as anyone with only one email will not be able to use your site. My problem is the users Profile email has to be visible in my setup as its how to contact the person so no option to hide it. Emails do not need to be publicly viewable for admins to see them. Admins have access to view anything and that is protected by the fact that only admin users can see admin content. But since its published I don’t want that email to be the same login email since people can easily copy the Profile email, click forgot password and send off and email to the actual user. I would vote for never publishing the user's email as those who are concerned about receiving spam will not agree to use a site where there email is available for all to see. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: What's __() function?
You should find useful info here: http://book.cakephp.org/view/162/Internationalizing-Your-Application Best, David Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Data validation rule (between) never returns true
@Dr. Loboto Thanks for the answer. That does make sense to me. @WebbedIT It also makes sense that providing they match I can take the confirm_password as the test for password length. Cheers for the help. On Mar 24, 9:13 am, WebbedIT p...@webbedit.co.uk wrote: most auth setups also have a password_confirm field and use that to validate password length etc. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: repeatedly call controller action through ajax
Hi John, thanks for your answer could you explain a bit further how to retrieve the condition and return it with the result? I've worked with php a long time now but i just recently delved into ajax so I still have to find my way around. And btw my normal page loading works without ajax I only want a action which reacts to specified events (like a change in the database) to be executed over and over again and do something if that certain event happens. Regards Alex On 24 Mrz., 08:09, John Andersen j.andersen...@gmail.com wrote: I am not sure how your page loading is working - with ajax or without - so here is what I would do based on your information: In the first ajax call to the bar action, retrieve the dynamic condition and return it together with the ajax result. Then act upon it as you want. Enjoy, John Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Behaviour is not attached automaticaly
Hi all! I created a simple model: class Photos extends AppModel { var $name = 'Photos'; var $actsAs = array('Aircraft'); } Put file 'aircraft.php' in app/models/behaviors'. It has only one method: class AircraftBehavior extends ModelBehavior { function setup($model, $settings = array()) { } function flyto($model, $from, $to) { echo Flying from {$from} to {$to} \nbr /; } } Then in my PhotosController I do call $this-Photo-flyto(toronto, monreal); and get the error SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'flyto' at line 1. It seems that the method flyto is treated as SQL command. If I add $this-Photo-Behaviors-attach('Aircraft'); before actual call of flyto method, then everything is all right. Why can this happens, that actAs does nothing? Best regards, Vadim. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: repeatedly call controller action through ajax
Ok, if your page is loading normaly, then pass the information to the view/layout and in there, make the decision to activate or not, the ajax request to the bar action. How you are going to do it is up to you, I have no idea :) of what information you use and how you have chosen to implement your solution to your web site! Enjoy, John On Mar 24, 11:32 am, alex bailey v...@planet-generals.de wrote: Hi John, thanks for your answer could you explain a bit further how to retrieve the condition and return it with the result? I've worked with php a long time now but i just recently delved into ajax so I still have to find my way around. And btw my normal page loading works without ajax I only want a action which reacts to specified events (like a change in the database) to be executed over and over again and do something if that certain event happens. Regards Alex On 24 Mrz., 08:09, John Andersen j.andersen...@gmail.com wrote: I am not sure how your page loading is working - with ajax or without - so here is what I would do based on your information: In the first ajax call to the bar action, retrieve the dynamic condition and return it together with the ajax result. Then act upon it as you want. Enjoy, John Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: scaffold isn't working
Hi, The models file name should be singular form of the DB. The problem is file name, after changing the filename it works as scaffolding On Jan 28, 3:17 am, BrendonKoz brendon...@hotmail.com wrote: Okay, I just re-read that. I don't know what he meant, but my last reply will probably fix the issue. On Jan 27, 11:27 am, BrendonKoz brendon...@hotmail.com wrote: I believe he meant the $name property within the controller. var $name = 'Author'; ...should be... var $name = 'Authors'; On Jan 26, 11:11 am, euromark dereurom...@googlemail.com wrote: but it is supposed to be plural class BooksController extends AppController { On 26 Jan., 16:30, andrei.b andrei.bogdan.m...@gmail.com wrote: I found the error. The name of the controllers was at the plural instead of singular. On Jan 26, 4:56 pm, andrei.b andrei.bogdan.m...@gmail.com wrote: I did that. The select looks like this: SELECT `Book`.`id`, `Book`.`isbn`, `Book`.`title`, `Book`.`description`, `Book`.`author_id` FROM `books` AS `Book` WHERE 1 = 1 LIMIT 20 I use Cake 1.2.5 and php 5.3.1 if this is relevant. On Jan 26, 4:50 pm, Jeremy Burns jeremybu...@me.com wrote: If it isn't already there, try turning debug to 2 as this clears the model cache. You can find the setting, which looks like this: Configure::write('debug', 2); ...in app/config/core.php Jeremy Burns On 26 Jan 2010, at 14:47, andrei.b wrote: Hello, I have 2 tables: authors(id, name, email) and books(id, title, author_id). I've created models for authors and books: class Author extends AppModel { var $name = 'Author'; var $hasMany = 'Book'; } class Book extends AppModel { var $name = 'Book'; var $belongsTo = 'Author'; } And the 2 controllers: class AuthorsController extends AppController{ var $name = 'Authors'; var $scaffold; } class BooksController extends AppController { var $name = 'Books'; var $scaffold; } When I runhttp://localhost/relationship/books/insteadofshowingat author the name of the autor it shows me the id of the author. Can somebody help me? Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpotherswiththeirCakePHP related questions. 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 athttp://groups.google.com/group/cake-php?hl=en-Hidequoted text - - Show quoted text -- Hide quoted text - - Show quoted text - Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Checking RequestHandler::isPost() vs Controller's data
It looks to be somewhat of a mess, but the bug is not in RequestHandler itself. When you create the form, if you don't specify it, FormHelper-create assigns the method POST or PUT to the form depending on whether the record already exists or not. So when there is a record (edit), the verb is PUT and not POST. One problem is that this verb is assigned to a hidden field in the form and cake uses the verb from there across the board on post back. So when submitted, isPost will not work but isPut will. I have no idea why a special hidden field is used instead of the HTTP verb itself, maybe there is good reason for that but it's very confusing. This is also contrary to the [arguable] consensus on mapping CRUD to HTTP verbs: * Create = PUT * Retrieve = GET * Update = POST * Delete = DELETE The above is arguable, some say that PUT and POST can be both used for Create and Update depending on some more subtle differences I will not get into here. - barduck On Mar 10, 8:01 pm, Miles J mileswjohn...@gmail.com wrote: The main problem I always would run into would that it would not recognized a POST, so the form would do nothing. I would usually have to submit it twice before it worked. Never figured out why it did that. On Mar 10, 7:03 am, Jimmy Bourassa jboura...@gmail.com wrote: Thanks Miles, Can you be a bit more specific regarding the bugs you've seen? Thanks, On 10 mar, 00:17, Miles J mileswjohn...@gmail.com wrote: Yes exactly. RequestHandler would force it only if the HTTP method is POST, where as $data would work no matter what source it came from. I prefer RequestHandler, but it has been buggy sometimes. On Mar 9, 6:10 pm, Jimmy Bourassa jboura...@gmail.com wrote: Hello, I realized that everyone seems to do an empty() call on $this-data in controllers in order to check if data has been posted or not. Is it just me or RequestHandler::isPostyields better results? This would allow to pre-fill Controller::$data in various situations. Thanks, Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: GUARDAR MULTIPLES REGISTROS
Maybe this can help you: http://book.cakephp.org/view/75/Saving-Your-Data On 23 mar, 12:24, ANDREA SANCHEZ ancasab...@gmail.com wrote: TENGO EL SIGUIENTE FORMULARIO div class=recordNotes index h2?php __('RecordNotes');? ?php if(isset($schedule)): ? ?php __('for');? ?php echo $schedule;? ?php endif;?/h2 ?php echo $form-create('RecordNote',array('action' = 'teacher_add'));? div class=input textlabel?php __('Subject');?/label ?php $options = array(); foreach ($subjects as $subject): $options[$subject['Subject']['id']] = $subject['Subject'] ['name']; endforeach; echo $form-select('subject_id', $options, null,null, false);? /div div class=input textlabel?php __('Teacher');?/label ?php $options = array(); foreach ($teachers as $teacher): $options[$teacher['User']['id']] = $teacher['User']['last_name'].' '.$teacher['User']['name']; endforeach; echo $form-select('teacher_id',$options,null,null,false); ?/div table cellpadding=0 cellspacing=0 tr th?php __('Student');?/th th?php __('Note');?/th /tr tr ? $i =0; foreach ($students as $student): ?td ? echo $form-label($student['Student']['last_name'].' '. $student['Student']['name']); $options = $student['Student']['id']; echo $form-hidden('student_id'.$i, array('value' = $options));? /td td ? echo $form-input('note'.$i);? /td ? $i= $i+1; ? /tr ?php endforeach; ? td colspan=3 ?php echo $form-end(__('Submit', true));?/td td align=leftp /fieldset /div /table /table /div /div COMO HAGO PARA GUARDAR MULTIPLES REGISTROS, CUANDO GUARDO ME QUEDAN LOS DATOS DE LA MATERIA Y EL PROFESOR, DE 1 REGISTRO PERO SIN DATOS DE NOTA NI ALUMNO. Q TENGO Q HACER??? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Behaviour is not attached automaticaly
Aren't you working with the wrong model? The model you created is being called Photos and you are using Photo on tour controller. Lucca Mordente On 24 mar, 07:13, Vadim Frolov fra...@gmail.com wrote: Hi all! I created a simple model: class Photos extends AppModel { var $name = 'Photos'; var $actsAs = array('Aircraft'); } Put file 'aircraft.php' in app/models/behaviors'. It has only one method: class AircraftBehavior extends ModelBehavior { function setup($model, $settings = array()) { } function flyto($model, $from, $to) { echo Flying from {$from} to {$to} \nbr /; } } Then in my PhotosController I do call $this-Photo-flyto(toronto, monreal); and get the error SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'flyto' at line 1. It seems that the method flyto is treated as SQL command. If I add $this-Photo-Behaviors-attach('Aircraft'); before actual call of flyto method, then everything is all right. Why can this happens, that actAs does nothing? Best regards, Vadim. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Validation from both model and controller not working
Hi, I have given validation in model. Also, I have given some validation in controller for checking the captcha code. After that, the application is not displaying the model validation errors. If I comment the controller code, model validation is working fine and displaying the errors. Both not working.. Model code (sample) class User extends AppModel { var $name = 'User'; var $validate = array( 'username' = 'notempty', 'firstname' = 'notempty' ); } Controller code if (!empty($this-data)) { $this-User-set($this-data); $this-User-create(); $captcha = $this-Session-read('CAPTCHA_CODE'); if (strtolower($captcha) != strtolower($this-data['User'] ['captcha'])) { $this-User-invalidate('captcha', __('Sorry, your entry did not match', true)); } if ($this-User-save($this-data, array('validate' = 'only'))) { if ($this-User-save($this-data, array('validate' = 'false'))) { $this-Session-setFlash(__('Registered successfully', true)); $this-redirect('success'); } }else { $this-Session-setFlash(__('Please, try again.', true)); } } I have replaced the if ($this-User-save($this-data, array('validate' = 'only'))) line with if ($this-User- validates()), then also it is not working. please help Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Behaviour is not attached automaticaly
I can't believe I was so blind! Thanks a lot! This is definitely the cause. Vadim. On 24 March 2010 14:12, Lucca Mordente luccamorde...@gmail.com wrote: Aren't you working with the wrong model? The model you created is being called Photos and you are using Photo on tour controller. Lucca Mordente On 24 mar, 07:13, Vadim Frolov fra...@gmail.com wrote: Hi all! I created a simple model: class Photos extends AppModel { var $name = 'Photos'; var $actsAs = array('Aircraft'); } Put file 'aircraft.php' in app/models/behaviors'. It has only one method: class AircraftBehavior extends ModelBehavior { function setup($model, $settings = array()) { } function flyto($model, $from, $to) { echo Flying from {$from} to {$to} \nbr /; } } Then in my PhotosController I do call $this-Photo-flyto(toronto, monreal); and get the error SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'flyto' at line 1. It seems that the method flyto is treated as SQL command. If I add $this-Photo-Behaviors-attach('Aircraft'); before actual call of flyto method, then everything is all right. Why can this happens, that actAs does nothing? Best regards, Vadim. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe from this group, send email to cake-php+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: retrieve related model data
cricket Again... thanks a lot for your help. It seems to work. When i debug, i get this: == Array ( [Port] = Array ( [id] = 1 [hardware_unit_id] = 1 [vlan_id] = 1 [port_employment_group_id] = 3 [uplink_id] = [active] = 1 [port_name] = 24 [port_index] = 0x22 [status] = 1 [duplex] = 10 [speed] = 100 [last_update] = 2009-03-12 11:30:21 [0] = Array ( [id] = 3 [hardware_unit_id] = 3 [vlan_id] = 2 [port_employment_group_id] = 3 [uplink_id] = 1 [active] = 0 [port_name] = 28 [port_index] = 0x26 [status] = 1 [duplex] = 10 [speed] = 100 [last_update] = 2009-03-12 11:30:21 [HardwareUnit] = Array ( [id] = 3 [staff_id] = 3 [room_id] = 3 [hardware_group_id] = 9 [hardware_type_id] = 2 [schenker_number] = 522 [active] = 1 [receptacle_port] = [serial_number] = 4gsd153-dg1253-6g351 [ip] = [user_login] = [purchase_date] = 2010-03-24 [support_end] = [leasing_end] = [additional_info] = das ist der zusatztext monitor ) === Could you help me to find out the code to retrieve schenker_number in the last part? Currently i retrieve this way (in my view): [code inside a foreach loop] td style=text-align:left?php echo $port['Port']['uplink_id']; ?/ td [/code] Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: retrieve related model data
To work this, start at the top and work your way down through the array: $this-data['Port'][0]['HardwareUnit']['schenker_number'] Jeremy Burns jeremybu...@me.com On 24 Mar 2010, at 14:25, sebb86 wrote: cricket Again... thanks a lot for your help. It seems to work. When i debug, i get this: == Array ( [Port] = Array ( [id] = 1 [hardware_unit_id] = 1 [vlan_id] = 1 [port_employment_group_id] = 3 [uplink_id] = [active] = 1 [port_name] = 24 [port_index] = 0x22 [status] = 1 [duplex] = 10 [speed] = 100 [last_update] = 2009-03-12 11:30:21 [0] = Array ( [id] = 3 [hardware_unit_id] = 3 [vlan_id] = 2 [port_employment_group_id] = 3 [uplink_id] = 1 [active] = 0 [port_name] = 28 [port_index] = 0x26 [status] = 1 [duplex] = 10 [speed] = 100 [last_update] = 2009-03-12 11:30:21 [HardwareUnit] = Array ( [id] = 3 [staff_id] = 3 [room_id] = 3 [hardware_group_id] = 9 [hardware_type_id] = 2 [schenker_number] = 522 [active] = 1 [receptacle_port] = [serial_number] = 4gsd153-dg1253-6g351 [ip] = [user_login] = [purchase_date] = 2010-03-24 [support_end] = [leasing_end] = [additional_info] = das ist der zusatztext monitor ) === Could you help me to find out the code to retrieve schenker_number in the last part? Currently i retrieve this way (in my view): [code inside a foreach loop] td style=text-align:left?php echo $port['Port']['uplink_id']; ?/ td [/code] Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Blank page when CakePHP is uploaded to the server
I've built a site in CakePHP 1.2, which is working fine locally. However, when I upload it to the server and then navigate to it, I get a blank page. The setup is exactly the same, and the .htaccess files haven't been changed from the downloaded ones. I've cleared the cache files in /app/tmp, but that hasn't helped. When I Google it, I didn't find anything that helped. I don't have access to the php.ini file, so I can't change that. I just don't know where to start looking, or what might be wrong. I'd be very grateful if someone could tell me where to start with this. Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Blank page when CakePHP is uploaded to the server
As a first best bet I would: - Enable debugging - that might reveal an error that's currently being hidden from you. - Clear the caches (empty the folders in /app/tmp/cache/). - Make sure the folders under /app/tmp/ are writable. - Look in the debug and error logs (both inside /app/tmp/logs) Jeremy Burns jeremybu...@me.com On 24 Mar 2010, at 15:17, WhyNotSmile wrote: I've built a site in CakePHP 1.2, which is working fine locally. However, when I upload it to the server and then navigate to it, I get a blank page. The setup is exactly the same, and the .htaccess files haven't been changed from the downloaded ones. I've cleared the cache files in /app/tmp, but that hasn't helped. When I Google it, I didn't find anything that helped. I don't have access to the php.ini file, so I can't change that. I just don't know where to start looking, or what might be wrong. I'd be very grateful if someone could tell me where to start with this. Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: try/catch action
The exceptions wouldn't be generated by a missing method. They are often generated by contacting other web-services or working with other applications running on the server (ie image generator) or my cache- engine. They are generally handled by exception handling in the Action. I was just looking for a backstop that can provide some universal handling for exceptions that aren't caught. This would be useful in the example I gave. Thanks for the link. I'll look into doing this the PHP 4/Cake way: the ErrorHandler class. But, does anybody have a good solution using Exceptions and try/catch? Thanks. On Mar 24, 2:46 am, John Andersen j.andersen...@gmail.com wrote: As far as I remember, you don't need to do try catch, just compare the current action against the actions defined in the controller. For example you can do the following (quick and dirty solution) in the AppController beforeFilter method: [code] if (!in_array($this-params['action'], get_class_methods($this))) { do your error processing} [/code] or even better, you can try to make your own cakeError processing. See:http://book.cakephp.org/view/154/Error-Handling Enjoy, John On Mar 24, 6:43 am, Josh joshs.silver...@gmail.com wrote: Hello I would like to somehow apply a try catch statement to all Actions as a backstop for any uncaught exceptions. I think this would be particularly helpful for Ajax Actions, because the catch statement could send back a default 4xx status code. Prototype's onFailure() function could then do the client-side error handling. How can I do this without wrapping the Action call with a try/catch in the cake dispatcher ($controller-dispatchMethod($params['action'], $params['pass']);) Does anybody have a suggestion or another workable strategy for gaining this functionality? Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: try/catch action
I've looked into the Cake Error Handling. Without try/catch it seems like there is a big loss in functionality. Exceptions allow you to handle unexpected behaviors outside of a normal case flow. CakeErrors seem intended for stopping the app and giving the user feedback. And, I am hesitant to mix CakeErrors and Exceptions. Does anybody have any comments on using try/catch in the dispatcher as a backstop for uncaught exceptions? On Mar 24, 11:28 am, Josh joshs.silver...@gmail.com wrote: The exceptions wouldn't be generated by a missing method. They are often generated by contacting other web-services or working with other applications running on the server (ie image generator) or my cache- engine. They are generally handled by exception handling in the Action. I was just looking for a backstop that can provide some universal handling for exceptions that aren't caught. This would be useful in the example I gave. Thanks for the link. I'll look into doing this the PHP 4/Cake way: the ErrorHandler class. But, does anybody have a good solution using Exceptions and try/catch? Thanks. On Mar 24, 2:46 am, John Andersen j.andersen...@gmail.com wrote: As far as I remember, you don't need to do try catch, just compare the current action against the actions defined in the controller. For example you can do the following (quick and dirty solution) in the AppController beforeFilter method: [code] if (!in_array($this-params['action'], get_class_methods($this))) { do your error processing} [/code] or even better, you can try to make your own cakeError processing. See:http://book.cakephp.org/view/154/Error-Handling Enjoy, John On Mar 24, 6:43 am, Josh joshs.silver...@gmail.com wrote: Hello I would like to somehow apply a try catch statement to all Actions as a backstop for any uncaught exceptions. I think this would be particularly helpful for Ajax Actions, because the catch statement could send back a default 4xx status code. Prototype's onFailure() function could then do the client-side error handling. How can I do this without wrapping the Action call with a try/catch in the cake dispatcher ($controller-dispatchMethod($params['action'], $params['pass']);) Does anybody have a suggestion or another workable strategy for gaining this functionality? Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Blank page when CakePHP is uploaded to the server
Thanks Jeremy. I tried all those things, but am no further on. - Debugging is set to 3, and isn't bringing up anything - Caches have all been cleared, and that didn't help - Made the folders writable - Debug and error logs don't have anything that helps - the most recent entries are from weeks ago, which would be from the local version. Even at that, they are all things I've since fixed. Any further ideas anyone? Thanks again for the suggestions! Sharon On Mar 24, 3:21 pm, Jeremy Burns jeremybu...@me.com wrote: As a first best bet I would: - Enable debugging - that might reveal an error that's currently being hidden from you. - Clear the caches (empty the folders in /app/tmp/cache/). - Make sure the folders under /app/tmp/ are writable. - Look in the debug and error logs (both inside /app/tmp/logs) Jeremy Burns jeremybu...@me.com On 24 Mar 2010, at 15:17, WhyNotSmile wrote: I've built a site in CakePHP 1.2, which is working fine locally. However, when I upload it to the server and then navigate to it, I get a blank page. The setup is exactly the same, and the .htaccess files haven't been changed from the downloaded ones. I've cleared the cache files in /app/tmp, but that hasn't helped. When I Google it, I didn't find anything that helped. I don't have access to the php.ini file, so I can't change that. I just don't know where to start looking, or what might be wrong. I'd be very grateful if someone could tell me where to start with this. Thanks! Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. 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 athttp://groups.google.com/group/cake-php?hl=en To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: retrieve related model data
Jeremy Thanks! :) That works. But now, i thought i was ready i noticed another problem. The debug output above is for a port, which has no value in the field uplink_id. But the port with id - 3 has value 1 in uplink_id. So port with id 3 points to port with id 1. Now, the problem is, that i need the hardware_unit in the table cell with the uplink_id (in my example port with id 3), not in the cell to which points this uplink_id (in my example port with id 1). Any ideas? [view retrieve code] td ?php echo $port['Port']['uplink_id']; ? ?php if ($port['Port']['uplink_id'] != NULL) { ? ?php echo (; echo $port['Port']['0']['HardwareUnit']['schenker_number']; echo ); } ?/td [/code] i despair of this problem :( Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Blank page when CakePHP is uploaded to the server
An update - I've discovered that I can't get access to the database at the moment. Could that be causing this? In the past, it has always triggered a more obvious error, but maybe for some reason it's just bailing out now? Sharon Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Blank page when CakePHP is uploaded to the server
Does your home page need db access? If so, try removing that code (or create a temporary dummy) and see if that comes through. Have you checked that mod_rewrite is enabled on the server too? Jeremy Burns jeremybu...@me.com On 24 Mar 2010, at 15:58, WhyNotSmile wrote: An update - I've discovered that I can't get access to the database at the moment. Could that be causing this? In the past, it has always triggered a more obvious error, but maybe for some reason it's just bailing out now? Sharon Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
making fpdf work in cakephp
I've been trying to make fpdf work in CakePHP (http:// bakery.cakephp.org/articles/view/pdf-helper-using-fpdf) with no success. When I add the pdf helper to the helpers array in my controller, I get the following error message in my view: Call to undefined function vendor() in...\views\helpers\fpdf.php on line 2. line 2 in my helper is: vendor('fpdf/fpdf'); Would anyone happen to know why I'm getting this error? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Blank page when CakePHP is uploaded to the server
Thanks Jeremy. DB access is back, so it must just have been a momentary problem - but it hasn't made my site appear! I'll try creating a dummy home page and see whether that helps. I don't know how to check mod_rewrite - I did have an earlier version of the site up before, and it worked fine, so I assume everything that's needed for CakePHP is on there. Thanks again. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
check if foreign key is used in other tables before delete data row
On 2 Mrz. 2009, 19:25, mscdex msc...@gmail.com wrote: On Mar 2, 7:20 am, krishan milepe...@gmail.com wrote: I usually do this sort of checking in the model validation or in the delete controller action before the deletion is attempted. Something like a find('count') or similar method to tocheckif the ID of the record to be deleted exists in a FK in some other table or record. You might also try the model's 'del' method which has a 'cascade' option (http://book.cakephp.org/view/690/del). Hello in addition to the topic above, i have the same problem and this suggestion sounds nice for me! I'd like to check if the ID of the record to be deleted exists in a foreign key in some other table (i have to check all associated tables) or record. Could someone help me to build an example for this? [code of my updated delete fuction in appController] function delete($id) { # check (with find('count') or something else) if the ID of the record to be deleted exists in a foreign key in some other table # if ( # the record is not used # ) { $this-{$this-modelClass}-del($id); $this-Session-setFlash('delete (id: '.$id.') works!'); } else { $this-Session-setFlash('Could not be deleted because of ...'); } $this-redirect(array ('action' = 'index')); } [/code] Could someone help me please? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: try/catch action
I believe you can just do something like this, especially if its an AJAX call and you want to simply return a json response. public function action() { try { // Do something here } catch(Exception $e) { echo json_encode(array( 'error' = true, 'message' = $e-getMessage() )); } } On Mar 24, 8:47 am, Josh joshs.silver...@gmail.com wrote: I've looked into the Cake Error Handling. Without try/catch it seems like there is a big loss in functionality. Exceptions allow you to handle unexpected behaviors outside of a normal case flow. CakeErrors seem intended for stopping the app and giving the user feedback. And, I am hesitant to mix CakeErrors and Exceptions. Does anybody have any comments on using try/catch in the dispatcher as a backstop for uncaught exceptions? On Mar 24, 11:28 am, Josh joshs.silver...@gmail.com wrote: The exceptions wouldn't be generated by a missing method. They are often generated by contacting other web-services or working with other applications running on the server (ie image generator) or my cache- engine. They are generally handled by exception handling in the Action. I was just looking for a backstop that can provide some universal handling for exceptions that aren't caught. This would be useful in the example I gave. Thanks for the link. I'll look into doing this the PHP 4/Cake way: the ErrorHandler class. But, does anybody have a good solution using Exceptions and try/catch? Thanks. On Mar 24, 2:46 am, John Andersen j.andersen...@gmail.com wrote: As far as I remember, you don't need to do try catch, just compare the current action against the actions defined in the controller. For example you can do the following (quick and dirty solution) in the AppController beforeFilter method: [code] if (!in_array($this-params['action'], get_class_methods($this))) { do your error processing} [/code] or even better, you can try to make your own cakeError processing. See:http://book.cakephp.org/view/154/Error-Handling Enjoy, John On Mar 24, 6:43 am, Josh joshs.silver...@gmail.com wrote: Hello I would like to somehow apply a try catch statement to all Actions as a backstop for any uncaught exceptions. I think this would be particularly helpful for Ajax Actions, because the catch statement could send back a default 4xx status code. Prototype's onFailure() function could then do the client-side error handling. How can I do this without wrapping the Action call with a try/catch in the cake dispatcher ($controller-dispatchMethod($params['action'], $params['pass']);) Does anybody have a suggestion or another workable strategy for gaining this functionality? Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Blank page when CakePHP is uploaded to the server
Do you have access to Apache's logs? What about php.ini? Can you see any static pages in webroot? Try adding a file, info.php, with: ?php phpinfo(); ? If that works, you can easily compare the local remote setups. Maybe something will jump out. And I recommend you set debug no higher than 2. At 3, Cake spits out *a lot* of data, especially if you've got associated models involved. On Mar 24, 12:09 pm, WhyNotSmile sharongilmor...@googlemail.com wrote: Thanks Jeremy. DB access is back, so it must just have been a momentary problem - but it hasn't made my site appear! I'll try creating a dummy home page and see whether that helps. I don't know how to check mod_rewrite - I did have an earlier version of the site up before, and it worked fine, so I assume everything that's needed for CakePHP is on there. Thanks again. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Building a submenu based on the current page_id
Hello, I'm building a submenu (which holds sub pages of the current page) into my cakephp site. This submenu is based on the current page_id, which I get from the URL. (...pages/view/13 for example) I have put this submenu into an element, that I call in my layout file. Now my question is, how can I build my submenu (with sub pages of the current page) based on the current page_id. (another way than just getting it from the URL, if possible? :)) Thanks in advance, mattyh88 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Find Output Thoughts (why the not remove ['ModelName'])
Hi. I've been working with Cake for a while and something always comes up to my mind when writing a view, which I'll share: We all know how Cake spits a simple find('first'), right: Array ( [ModelName] = Array ( [id] = 83 [field1] = value1 ) [AssociatedModelName] = Array ( [id] = 1 [field1] = value1 ) ) Now, I find it tiresome to have to type the ['ModelName'] everytime I want to play with the data. And also sometimes it seems a little redundant. For example: What do you usually do when finding an article: $article = $this-Articles-findById(1); (using $data all the time seems little intuitive for me since sometimes we have a lot of different data shipping to the view) To get the name of the article we would use $article['Article'] ['name']. See... article-Article-name. And I keep thinking that since, by convention, all model names are CamelCased, and fieldnames are lowercased, and arrays are case sensitive, usually, we wouldn't have a collision and then we would have more beatiful data: $article['name']; $article['Author']['name']; and so forth so, what am I missing here? :-) Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Building a submenu based on the current page_id
This might help... http://articles.classoutfit.com/2009/11/cakephp-dynamic-navigation-bars/ Jeremy Burns jeremybu...@me.com On 24 Mar 2010, at 19:12, mattyh88 wrote: Hello, I'm building a submenu (which holds sub pages of the current page) into my cakephp site. This submenu is based on the current page_id, which I get from the URL. (...pages/view/13 for example) I have put this submenu into an element, that I call in my layout file. Now my question is, how can I build my submenu (with sub pages of the current page) based on the current page_id. (another way than just getting it from the URL, if possible? :)) Thanks in advance, mattyh88 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: try/catch action
That's what I have more or less. But, what I want to do is apply that in bulk to all actions as a backstop to any uncaught Exceptions. I gave the above example to demonstrate when this might be useful. To clarify, I have maybe 20 Ajax actions, all of which are called with the Prototype Request object. I want to make sure that the onFailure function on the Prototype Request object is always triggered if there is an Exception thrown in the back-end (unless that Exception is caught earlier). It would be redundant to wrap the logic on the interior of each action with a try/catch statement and generic handling. To avoid this redundancy, I would like to wrap the action call in the dispatcher with generic Exception handling. On Mar 24, 1:49 pm, Miles J mileswjohn...@gmail.com wrote: I believe you can just do something like this, especially if its an AJAX call and you want to simply return a json response. public function action() { try { // Do something here } catch(Exception $e) { echo json_encode(array( 'error' = true, 'message' = $e-getMessage() )); } } On Mar 24, 8:47 am, Josh joshs.silver...@gmail.com wrote: I've looked into the Cake Error Handling. Without try/catch it seems like there is a big loss in functionality. Exceptions allow you to handle unexpected behaviors outside of a normal case flow. CakeErrors seem intended for stopping the app and giving the user feedback. And, I am hesitant to mix CakeErrors and Exceptions. Does anybody have any comments on using try/catch in the dispatcher as a backstop for uncaught exceptions? On Mar 24, 11:28 am, Josh joshs.silver...@gmail.com wrote: The exceptions wouldn't be generated by a missing method. They are often generated by contacting other web-services or working with other applications running on the server (ie image generator) or my cache- engine. They are generally handled by exception handling in the Action. I was just looking for a backstop that can provide some universal handling for exceptions that aren't caught. This would be useful in the example I gave. Thanks for the link. I'll look into doing this the PHP 4/Cake way: the ErrorHandler class. But, does anybody have a good solution using Exceptions and try/catch? Thanks. On Mar 24, 2:46 am, John Andersen j.andersen...@gmail.com wrote: As far as I remember, you don't need to do try catch, just compare the current action against the actions defined in the controller. For example you can do the following (quick and dirty solution) in the AppController beforeFilter method: [code] if (!in_array($this-params['action'], get_class_methods($this))) { do your error processing} [/code] or even better, you can try to make your own cakeError processing. See:http://book.cakephp.org/view/154/Error-Handling Enjoy, John On Mar 24, 6:43 am, Josh joshs.silver...@gmail.com wrote: Hello I would like to somehow apply a try catch statement to all Actions as a backstop for any uncaught exceptions. I think this would be particularly helpful for Ajax Actions, because the catch statement could send back a default 4xx status code. Prototype's onFailure() function could then do the client-side error handling. How can I do this without wrapping the Action call with a try/catch in the cake dispatcher ($controller-dispatchMethod($params['action'], $params['pass']);) Does anybody have a suggestion or another workable strategy for gaining this functionality? Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: repeatedly call controller action through ajax
´I think I've got it to work by doing as you said with a few compromises here and there : ) Big thanks I really appreciate your help. Regards Alex On 24 Mrz., 11:29, John Andersen j.andersen...@gmail.com wrote: Ok, if your page is loading normaly, then pass the information to the view/layout and in there, make the decision to activate or not, the ajax request to the bar action. How you are going to do it is up to you, I have no idea :) of what information you use and how you have chosen to implement your solution to your web site! Enjoy, John Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Trailing Slash redirect (SEO) and CakePHP Forms
Hi there! I have a Problem with my App. In my .htaccess, i added some lines to redirect the user if the url ends without a slash to the same page with a slash. For example: redirect /posts/view/2 to /posts/view/2/ Now, I have a form /posts/add/. I use the Cakehelper to create it, and it makes a form action=/posts/add ... tag. If the user now submits the form, he gets redirected since the action says /posts/add and not /posts/add/ and ALL post data get lost :( Found only this post with the same problem: http://groups.google.com/group/cake-php/browse_thread/thread/b98f3ccd0727dba4/721d4f9cf1120e2e?lnk=gstq=canonicalization#721d4f9cf1120e2e Hope anyone can help me with this.. Thanks! Andi Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: try/catch action
I do not believe there is a way that you can apply this functionality to multiple actions, it would have to be written out in each one. The most I can see is doing this: public function action() { try { // Do something here } catch(Exception $e) { $this-_throwError($e-getMessage()); } } protected function _throwError($msg) { echo json_encode(array( 'error' = true, 'message' = $msg )); } On Mar 24, 1:11 pm, Josh joshs.silver...@gmail.com wrote: That's what I have more or less. But, what I want to do is apply that in bulk to all actions as a backstop to any uncaught Exceptions. I gave the above example to demonstrate when this might be useful. To clarify, I have maybe 20 Ajax actions, all of which are called with the Prototype Request object. I want to make sure that the onFailure function on the Prototype Request object is always triggered if there is an Exception thrown in the back-end (unless that Exception is caught earlier). It would be redundant to wrap the logic on the interior of each action with a try/catch statement and generic handling. To avoid this redundancy, I would like to wrap the action call in the dispatcher with generic Exception handling. On Mar 24, 1:49 pm, Miles J mileswjohn...@gmail.com wrote: I believe you can just do something like this, especially if its an AJAX call and you want to simply return a json response. public function action() { try { // Do something here } catch(Exception $e) { echo json_encode(array( 'error' = true, 'message' = $e-getMessage() )); } } On Mar 24, 8:47 am, Josh joshs.silver...@gmail.com wrote: I've looked into the Cake Error Handling. Without try/catch it seems like there is a big loss in functionality. Exceptions allow you to handle unexpected behaviors outside of a normal case flow. CakeErrors seem intended for stopping the app and giving the user feedback. And, I am hesitant to mix CakeErrors and Exceptions. Does anybody have any comments on using try/catch in the dispatcher as a backstop for uncaught exceptions? On Mar 24, 11:28 am, Josh joshs.silver...@gmail.com wrote: The exceptions wouldn't be generated by a missing method. They are often generated by contacting other web-services or working with other applications running on the server (ie image generator) or my cache- engine. They are generally handled by exception handling in the Action. I was just looking for a backstop that can provide some universal handling for exceptions that aren't caught. This would be useful in the example I gave. Thanks for the link. I'll look into doing this the PHP 4/Cake way: the ErrorHandler class. But, does anybody have a good solution using Exceptions and try/catch? Thanks. On Mar 24, 2:46 am, John Andersen j.andersen...@gmail.com wrote: As far as I remember, you don't need to do try catch, just compare the current action against the actions defined in the controller. For example you can do the following (quick and dirty solution) in the AppController beforeFilter method: [code] if (!in_array($this-params['action'], get_class_methods($this))) { do your error processing} [/code] or even better, you can try to make your own cakeError processing. See:http://book.cakephp.org/view/154/Error-Handling Enjoy, John On Mar 24, 6:43 am, Josh joshs.silver...@gmail.com wrote: Hello I would like to somehow apply a try catch statement to all Actions as a backstop for any uncaught exceptions. I think this would be particularly helpful for Ajax Actions, because the catch statement could send back a default 4xx status code. Prototype's onFailure() function could then do the client-side error handling. How can I do this without wrapping the Action call with a try/catch in the cake dispatcher ($controller-dispatchMethod($params['action'], $params['pass']);) Does anybody have a suggestion or another workable strategy for gaining this functionality? Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
How do you hide children using the Tree Helper?
Hello, I'm using find('threaded') and the Tree Helper (http:// bakery.cakephp.org/articles/view/tree-helper-1). My categories are up to 4 levels deep, but I only want to show the top parent and it's direct children for my navigation bar. I'm hoping to remove the children from the output. I don't want to hide the children using display: none. Thank you, -Kevin Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: retrieve related model data
On Mar 24, 11:57 am, sebb86 kahlc...@googlemail.com wrote: Jeremy Thanks! :) That works. But now, i thought i was ready i noticed another problem. The debug output above is for a port, which has no value in the field uplink_id. But the port with id - 3 has value 1 in uplink_id. So port with id 3 points to port with id 1. Now, the problem is, that i need the hardware_unit in the table cell with the uplink_id (in my example port with id 3), not in the cell to which points this uplink_id (in my example port with id 1). Any ideas? [view retrieve code] td ?php echo $port['Port']['uplink_id']; ? ?php if ($port['Port']['uplink_id'] != NULL) { ? ?php echo (; echo $port['Port']['0']['HardwareUnit']['schenker_number']; echo ); } ?/td [/code] i despair of this problem :( That doesn't work? It looks as though it should. Maybe I'm misunderstanding your question. But I don't understand why there's an array key 0. It should be 'PortUplink', I think. What was the exact find() you used? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: making fpdf work in cakephp
You're using the old syntax. Use App::import('Vendor', 'FPDF'); If that doesn't work, try: App::import('Vendor', 'FPDF', array('file' = 'fpdf/fpdf.php')); On Mar 24, 11:20 am, butterlamb cjwilb...@gmail.com wrote: I've been trying to make fpdf work in CakePHP (http:// bakery.cakephp.org/articles/view/pdf-helper-using-fpdf) with no success. When I add the pdf helper to the helpers array in my controller, I get the following error message in my view: Call to undefined function vendor() in...\views\helpers\fpdf.php on line 2. line 2 in my helper is: vendor('fpdf/fpdf'); Would anyone happen to know why I'm getting this error? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Validation from both model and controller not working
I'm not 100% sure of this, but I think that the automatic validation done from save() is overwriting the model's $validationErrors. In any case, what you should be doing is only calling save() if the captcha_code matches. So, use an if/else block: if (strtolower($captcha) != strtolower($this-data['User'] ['captcha'])) { $this-User-invalidate('captcha', __('Sorry, your entry did not match', true)); $this-Session-setFlash(__('CAPTCHA code does not match', true)); } else { if ($this-User-save($this-data, array('validate' = 'only'))) { if ($this-User-save($this-data, array('validate' = 'false'))) { $this-Session-setFlash(__('Registered successfully', true)); $this-redirect('success'); } } else { $this-Session-setFlash(__('Please, try again.', true)); } } On Mar 24, 9:31 am, Binu bino...@gmail.com wrote: Hi, I have given validation in model. Also, I have given some validation in controller for checking the captcha code. After that, the application is not displaying the model validation errors. If I comment the controller code, model validation is working fine and displaying the errors. Both not working.. Model code (sample) class User extends AppModel { var $name = 'User'; var $validate = array( 'username' = 'notempty', 'firstname' = 'notempty' ); } Controller code if (!empty($this-data)) { $this-User-set($this-data); $this-User-create(); $captcha = $this-Session-read('CAPTCHA_CODE'); if (strtolower($captcha) != strtolower($this-data['User'] ['captcha'])) { $this-User-invalidate('captcha', __('Sorry, your entry did not match', true)); } if ($this-User-save($this-data, array('validate' = 'only'))) { if ($this-User-save($this-data, array('validate' = 'false'))) { $this-Session-setFlash(__('Registered successfully', true)); $this-redirect('success'); }}else { $this-Session-setFlash(__('Please, try again.', true)); } } I have replaced the if ($this-User-save($this-data, array('validate' = 'only'))) line with if ($this-User- validates()), then also it is not working. please help Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: How do you hide children using the Tree Helper?
The last param for generateTreeList is $recursive, which is the number of levels to fetch. http://api.cakephp.org/class/tree-behavior#method-TreeBehaviorgeneratetreelist On Mar 24, 5:09 pm, SacoDesign sign...@sacodesign.com wrote: Hello, I'm using find('threaded') and the Tree Helper (http:// bakery.cakephp.org/articles/view/tree-helper-1). My categories are up to 4 levels deep, but I only want to show the top parent and it's direct children for my navigation bar. I'm hoping to remove the children from the output. I don't want to hide the children using display: none. Thank you, -Kevin Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Empty relation belongsto 1.3
has something changed in ver 1.3 coresponding to how empty relations are presented? Whenever i use 0 or null as foreign-key i get something like (so its same as it's always been with hasOne relations): [Webpage] = Array ( [id] = 1 [created] = 2008-04-17 15:06:22 [modified] = 2010-03-24 16:43:57 [name] = Home Webpage [myforeign_id]=0 ) [Myforeign] = Array ( [id] = [created] = [modified] = [name] = ) I believe in previous versions array would look more like: [Webpage] = Array ( [id] = 1 [created] = 2008-04-17 15:06:22 [modified] = 2010-03-24 16:43:57 [name] = Home Webpage [myforeign_id]=0 ) [Myforeign] = Array ( ) What i believe does make more sense. So here comes next question: How should i check if relation is empty? empty($arr[Myforeign][id])??? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Saving form does not save item corresponding to select input type
I have a controller where i get the user roles and set them so they can be displayed on the view as a select list within a form. This part is OK, but when i Save the form all the fields but this field ( role ) is not saved, all other fields including the rAdiO button selection are saved, do i need to do something else ? here's the relevant code: in users_controller: var $belongsTo = array('Role' = array ( 'className' = 'Role', 'foreignKey'='role_id' )); . $this-set('roles',$this-Role-find('list', array('fields'=array('Role.id','Role.role'), 'order'='Role.role DESC'))); in roles_controller: var $name='Roles'; var $hasMany='User'; in user register view: echo $form-input('rol',array('options'=$roles) ); browser shows: INSERT INTO `users` (`username`, `password`, `email`, `ext`, `status`, `modified`, `created`) (role should be right after ext. ) Any help is appreciated, I've got much to learn Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Saving form does not save item corresponding to select input type
On Mar 24, 4:29 pm, hvannia hvan...@gmail.com wrote: I have a controller where i get the user roles and set them so they can be displayed on the view as a select list within a form. This part is OK, but when i Save the form all the fields but this field ( role ) is not saved, all other fields including the rAdiO button selection are saved, do i need to do something else ? The first thing I'd do in that situation is place die(debug($this- data)); right after the if (!empty($this-data)) line. here's the relevant code: in users_controller: var $belongsTo = array('Role' = array ( 'className' = 'Role', 'foreignKey'='role_id' )); . $this-set('roles',$this-Role-find('list', array('fields'=array('Role.id','Role.role'), 'order'='Role.role DESC'))); in roles_controller: var $name='Roles'; var $hasMany='User'; in user register view: echo $form-input('rol',array('options'=$roles) ); Is that a typo? Try: echo $form-input('User.role_id',array('options'=$roles) ); browser shows: INSERT INTO `users` (`username`, `password`, `email`, `ext`, `status`, `modified`, `created`) (role should be right after ext. ) Any help is appreciated, I've got much to learn Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Js helper and multiple effects
I'm using the Js helper in 1.3 for Ajax pagination, adding a fadeOut fadeIn effect to my content div. Can I produce two simultaneous effects? For example, can I fade out my content div and show my progress/spinner div, then hide my progress/ spinner div and fade in my content div? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.