Re: Error saving i18n
var $model = null; function setup($model, $config = array()){ $this-settings[$model-alias] = array_merge($this-_defaults, $config); $this-model = $model; } do i have to add $Model-set() also On Wed, Dec 28, 2011 at 1:31 PM, Tilen Majerle tilen.maje...@gmail.com wrote: how do you set data in the behavior ? do you use $Model-set() or ? -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/12/28 Constantin.FF constantin...@gmail.com I am using Behavior which beforeSave sets the title of the post. I am using this for attachments to set title, slug, create thumbs and so on .. With the testing till now these are the results: Set title inside: -Behavior beforeSave - does not save inside i18n table -Model bofereSave - does not save inside i18n table -Controller before $this-Attachment-save($this-data) - Working! What are my options to use only a Behavior to set the title? I guess that this error appears because storing entry inside i18n table happens before setting the title in the Behavior. So first it tries to save record inside i18n, but still there is no title and it does not save anything. After that saving applying the Behavior, which sets the title and saves the record in the 'attachments' table. How to debug and see, what is the data before inserting in the model and i18n tables? Any ideas for the error? -- 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 -- 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 -- 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
Re: Error saving i18n
absolutely the same result after adding $model-set(array('title' = $title, 'body' = $title)); at the end of beforeSave -- 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
Re: CakePHP does not save multilanguage attachment
Where should I set the $this-data['Attachment']['title'] = $this-data['Attachment']['attachment']['title']; With the testing till now these are the results: Set title inside: Behavior beforeSave - does not save inside i18n table Model bofereSave - does not save inside i18n table Controller before $this-Attachment-save($this-data) - Working! What are my options to use only a Behavior to set the title? I guess that this error is because the save inside i18n table is before setting the title in the Behavior, so first it tries to save record inside i18n but still there is no title and does not save anything and after that saving applying the Behavior which sets the title and saves the record in the 'nodes' table. On Thu, Nov 24, 2011 at 9:35 AM, msujit shoes...@gmail.com wrote: For now i have to set my image field in controller before saving it as i am hurry with my project.So i have to use another component to upload file and get filename lik $this-request-data['HowItWork'] ['image']=$this-uploadFile-upload(...); like public function admin_add() { if ($this-request-is('post')) { $fileUploaded = $this-Fileupload- uploadFiles('img'.'/'.HOW_IT_WORKS_FOLDER, $this-request- data['HowItWork']['upload_image'],null,'image'); if(empty($fileUploaded['urls'])) { $this-request-data['HowItWork'] ['upload_image']=; }else{ $this-request-data['HowItWork'] ['upload_image']=dummy; $this-request-data['HowItWork']['image']= $fileUploaded['urls'][0]; } $this-HowItWork-create(); if ($this-HowItWork-save($this-request-data)) { $this-Session-setFlash(__('The how it work has been saved')); $this-redirect(array('action' = 'index')); } else { $this-Session-setFlash(__('The how it work could not be saved. Please, try again.'),'error_msg'); } } } It works as it should be but I don't understand one thing though.When in set $this-data['HowItWork']['image'] in beforeSave() function in my model(like previous post) it doesn't work and doesn't get saved in i18n table.What am i doing wrong in the AppModel?I still want to use my old function to upload file from AppModel cause it doesn't require any coding in my controller and works for others controller as well.So still looking for solutions On Nov 24, 10:25 am, msujit shoes...@gmail.com wrote: Ye as i said earlier i am using a function in beforeSave to upload the image and set a variable to that uploaded image name.This was fine when there was no i18n table.I used this in my other projects which doesn't have multilanguage.But it's not working for i18n table.I am using 'upload_image' as file field in my form and then set the uploaded filename in 'image' field in table to be stored.Here are my function: In my child HowItWork model: function beforeSave() { return $this- upload_image('img/'.HOW_IT_WORKS_FOLDER,'image'); } In my parent AppModel: function upload_image($path,$field='image') { if( isset( $this-data[$this-alias]['upload_image'] ) ) { $this-file_path=$path; if(!empty($this-data[$this-alias]['prev_image']) empty($this-data[$this-alias]['upload_image']['name'])){ $this-data[$this-alias]['upload_image']=$this-data[$this-alias]['prev_image']; return true; } $this-create_folder($this-file_path); $filename=$this-check_filename($this-file_path,$this-data[$this-alias]['upload_image']['name']); $this-copy_file($this-data[$this-alias]['upload_image'] ['tmp_name'], $this-file_path.$filename); $this-data[$this-alias][$field]=$filename; if(!empty($this-data[$this-alias]['prev_image'])){ $this-delete_file($path.$this-data[$this-alias] ['prev_image']); } } return true; } On Nov 24, 1:47 am, Constantin.FF constantin...@gmail.com wrote: @msujit do you use a Behavior in your attachment model to set the title and to create thumbs before inserting them in the database or everything is inside the model? I have tested to set a new 'title' field in me form and this title got inside the i18n table. On Nov 23, 5:43 pm, Constantin FF constantin...@gmail.com wrote: I created new Debugtranslate Behavior just to find the reason of not saving the attachment title and body in the i18n table Here is the behavior ?php App::import('Behavior', 'Translate'); class
Re: CakePHP does not save multilanguage attachment
Still not solved! And I dont get anything saved in the i18n table Attachment Model: var $actsAs = array('Tree', 'Translate' = array( 'title' = 'titleTranslation', 'body' = 'bodyTranslation' ) ); The View and Controller are just the classic once On Wed, Nov 23, 2011 at 1:20 PM, msujit shoes...@gmail.com wrote: Hai, Did you managed to solve it?I am also having exact proble.I am trying to save image string to i18n table but it's not saving but other fileds like title,content are saved in i18n. On Nov 23, 2:05 pm, Constantin.FF constantin...@gmail.com wrote: My Attachment model actAs Translate to be able to translate the image titles, I get the attachment saved in it's attachments table, but nothing goes to the i18n table. This is the beforeSave model data: Array ( [Attachment] = Array ( [parent_id] = 0 [type] = Attachment [status] = 1 [promoted] = 0 [attachment] = Array ( [name] = bla-bla-picture.gif [type] = image/gif [tmp_name] = /tmp/phpVTolMj [error] = 0 [size] = 26886 ) [updated] = 2011-11-22 18:20:49 [created] = 2011-11-22 18:20:49 [lft] = 33 [rght] = 34 [body] = bla-bla-picture.gif [title] = Bla Bla Picture [mime_type] = image/gif [attachmentSize] = 26886 [path] = /img/attachments/ ) ) How to debug and see what is the data before inserting in the model and i18n tables? Any ideas for the error? -- 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 -- 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
Re: CakePHP does not save multilanguage attachment
I created new Debugtranslate Behavior just to find the reason of not saving the attachment title and body in the i18n table Here is the behavior ?php App::import('Behavior', 'Translate'); class DebugtranslateBehavior extends TranslateBehavior { function setup($Model, $settings) { if (!isset($this-__settings[$Model-alias])) { $this-__settings[$Model-alias] = array( 'fields' = array(), ); } if (!is_array($settings)) { $settings = array(); } $this-__settings[$Model-alias] = array_merge($this-__settings[$Model-alias], $settings); //setup Translate behavior with translatable fields return parent::setup($Model, $this-__settings[$Model-alias]['fields']); } function beforeSave($Model) { parent::beforeSave($Model, $created); pr($Model);die; return true; } } ? If the Debugtranslate behavior is attached to some ordinari model saving a post I get this inside the $Model array: Node Object ( [Behaviors] = BehaviorCollection Object ( [Debugtranslate] = DebugtranslateBehavior Object ( [runtime] = Array ( [Node] = Array ( [beforeSave] = Array ( [title] = test [body] = test-node ) ) ) ) ) ) BUT when saving attachment those fields does not exists. What more can I look for? On Wed, Nov 23, 2011 at 2:15 PM, DigitalDude e.blumsten...@googlemail.com wrote: Hey, @msujlt: you should always 'name' your tanslated fields, but I think cake does not force this. You then should remove the old field from the table (e.g. table attachments, field title). When you SAVE your racords (add/edit), you have to set the locale for your model: $this-Attachment-locale = 'eng'; Note: I don't know what locales are defined in your app. Also, there can be differences when your locales are build like en-gb, the locale will be eg_gb. Try doing that, it will work but I guess you'll have to test it out with the locales of your app... -- 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 -- 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
Re: Redirect depending on form field
It is a bit more complicated and not always I need to redirect to the referer. The controller checks if there is a redirect_id value setup in the submited form and changes the default redirect with the one from the form. After submitting the form, if I pr the redirect_id i get for example: array(action = browse, [0] = 54) so ... so far it is working, also if manually i go to the /browse/54 url everything is fine and working And the only way I was able to pass an array into the form was to encode it. If there is some other better way, please advise. On Fri, Nov 18, 2011 at 2:54 PM, AD7six andydawso...@gmail.com wrote: On Friday, 18 November 2011 13:24:16 UTC+1, Constantin.FF wrote: I am trying to get page redirected (after add or edit) depending on a field of the form. Here is what I have done so far: View: ... $back_link = array('action' = 'browse', $this-Form- value('Post.parent_id')); echo $this-Form-hidden('redirect_id', array('value' = json_encode($back_link))); why do you need to json encode the referer(ish) url ... Controller: ... $redirect = (array)json_decode($this-data['redirect_id']); $this-redirect($redirect); ... When I pr() the $redirect , everything looks just as it should but i get redirected to the browse action without any id after it. are you sure about that. put it through Router::url and/or check that /foo/123 isn't redirecting to /foo How to make this working, is it necessary to use separated fields in the view for controller, action, id. Or if you can advise any other, more simple method to do this. pass the url as a string (why do array - encode - decode - string, when you could simply do array - string) - or if you are trying merely to go back where you were when the form was submitted - use $this-referer() (either directly or by storing the current url in your go back here form field AD -- 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 -- 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
Re: Redirect depending on form field
Done, using multiple fields :/ foreach($back_link AS $o = $v){ echo $this-Form-hidden(redirect.$o, array('value' = $v)); } On Fri, Nov 18, 2011 at 6:08 PM, AD7six andydawso...@gmail.com wrote: On Friday, 18 November 2011 17:00:40 UTC+1, Constantin.FF wrote: It is a bit more complicated and not always I need to redirect to the referer. The controller checks if there is a redirect_id value setup in the submited form and changes the default redirect with the one from the form. After submitting the form, if I pr the redirect_id i get for example: array(action = browse, [0] = 54) so ... so far it is working, also if manually i go to the /browse/54 url everything is fine and working And the only way I was able to pass an array into the form was to encode it. If there is some other better way, please advise $passThisString = Router::url($theArray); don't $needlessly = json_encode($theArray); AD -- 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 -- 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
Re: Slow reorder TreeBehaviour
Not a deja vu, just decided that will be much more comfortable to use a field with an order number and just once to click Save order than continuously clicking the moveDown or moveUp links until the desired position. Will check the queries On Fri, Oct 28, 2011 at 11:46 AM, AD7six andydawso...@gmail.com wrote: On Oct 28, 10:09 am, Constantin.FF constantin...@gmail.com wrote: I need my tree sorted by each post sort value. Here is the function dealing with this. But it is executed extremely slow if some of the parents has more than 20-30 children function _sortPosts($newSort){ foreach ($newSort AS $id = $value) { if(is_numeric($value['sort'])){ $this-Post-updateAll(array('Post.sort' = $value['sort']), array('Post.id' = $id)); } else { $this-Session-setFlash(__('Non-numeric value given.', true), 'default', array('class' = 'error')); $this-redirect($this-referer()); } } foreach(array_keys($this-data['Post']) as $parent){ $this-Post-reorder(array('id' = $parent, 'field' = 'Post.sort', 'order' = 'ASC', 'verify' = true)); } why are you (still? Or do I just have deja vu) using another field to store the sort order - that's what lft is. if you _just_ call moveDown on each post in the order you want them to appear the tree will be in the order you expect. } Example: 38 posts, 8 parents and 30 children 5518 queries took 6028 ms Page rendered in 20032ms. Is there some other way to do this reorder without such a delay? The number of queries there most likely indicates an error in the tree behavior (145 queries per post) - if you look at what those queries are, you'll most likely be able to identify it and submit a pull request. AD -- 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 -- 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
Re: Slow reorder TreeBehaviour
Is there a better way for doing that? There is something similar in other CSM like joomla On Fri, Oct 28, 2011 at 12:11 PM, AD7six andydawso...@gmail.com wrote: On Oct 28, 10:58 am, Constantin FF constantin...@gmail.com wrote: Not a deja vu, just decided that will be much more comfortable to use a field with an order number and just once to click Save order than continuously clicking the moveDown or moveUp links until the desired position. Who suggested doing that? -- 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 -- 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
Re: Slow reorder TreeBehaviour
Thanks for the time and ideas. I continue working on both methods. On Fri, Oct 28, 2011 at 1:47 PM, AD7six andydawso...@gmail.com wrote: On Oct 28, 12:37 pm, Constantin.FF constantin...@gmail.com wrote: Probably this could work but will be almost impossible to calculate the step for moveDown _WHY_ would you need to calculate that? The suspicion arises that you aren't reading much of what I write. of each post also in this action are involved parents and children so in the $newSort each post is as post_id = order number. So if I do it like you suggested, first I will have to separate posts with same parent_id and then to moveDown each of them. Well I don't know what your interface is, but whatever it is the code you're writing, and the extra sort field, is not necessary to achieve what you're doing. Visually I'd implement what you're doing as 1) move everything on the screen 2) click the save button. It's not that hard. You might also just want to use a materialized path (add a field called position, store 1.1.1, 1.1.2, 1.1.3 in it and sort by this whenever you render your data). But I kind of give up trying to explain how to use the tree behavior... have fun. AD -- 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 -- 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
Re: Moving part of a Tree in other section
there was another issue in the post ids, after fixing it everything works. I'm just updating the parent_id of the post. Is this enough ? On Sun, Oct 23, 2011 at 8:10 PM, Jon Bennett jmbenn...@gmail.com wrote: Just changing the parent_id. How to change the tree also? How are you changing the parent_id? -- 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 -- 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
Re: Moving part of a Tree in other section
Just changing the parent_id. How to change the tree also? On Sat, Oct 22, 2011 at 12:21 PM, WebbedIT p...@webbedit.co.uk wrote: What code are you using to move the post with children and what error do you get? On Oct 22, 2:48 am, Constantin.FF constantin...@gmail.com wrote: My Post model have Tree behavior, and everything work just fine. Each post has a parent_id and lft,rght column. If I create and move posts in single level, everything is OK. But I get an error when I try to move a post which has one or more children. How to deal with this? 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 -- 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