Re: search only entered fields
Unless someone has a better idea what about: (p.s. didn't test this so read it as pseudo code) foreach ($sonditions as $field=$value ) { if(!empty($value)) $arrconditions[$field]=$value; } findAll($arrconditions, hashkash wrote: Hi! I searched the group for my problem but in vain. Sorry if this is redundant. I have created a search form having 4 fields to be filled up. I would like to base my search only on fields that have been filled up.With my current findall() Im not able to do so. How do I build the array string based on filled up fields? I have assigned a buildsearch value i.e if the field is entered = 1 else = 0.In regular PHP i can create a buildsearchstring function but with cake Im unable to figure out how to do so. This is my findall() $this-set('results', $this-Equipment- findAll(array('Equipment.owner'=$conditions['Equipment'] ['owner'],'Equipment.incharge'=$conditions['Equipment'] ['incharge'],'Equipment.eqno'=$conditions['Equipment'] ['eqno'],'Equipment.type'=$conditions['Equipment'] ['type']),'',Equipment.owner ASC,'','',0)); Hoping for some help! Thanks! Kashyap --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: search only entered fields
Minor corrections below Unless someone has a better idea what about: (p.s. didn't test this so read it as pseudo code) foreach ($sonditions['Equipment'] as $field=$value ) { if(!empty($value)) $arrconditions['Equipment.'.$field]=$value; } findAll($arrconditions, hashkash wrote: Hi! I searched the group for my problem but in vain. Sorry if this is redundant. I have created a search form having 4 fields to be filled up. I would like to base my search only on fields that have been filled up.With my current findall() Im not able to do so. How do I build the array string based on filled up fields? I have assigned a buildsearch value i.e if the field is entered = 1 else = 0.In regular PHP i can create a buildsearchstring function but with cake Im unable to figure out how to do so. This is my findall() $this-set('results', $this-Equipment- findAll(array('Equipment.owner'=$conditions['Equipment'] ['owner'],'Equipment.incharge'=$conditions['Equipment'] ['incharge'],'Equipment.eqno'=$conditions['Equipment'] ['eqno'],'Equipment.type'=$conditions['Equipment'] ['type']),'',Equipment.owner ASC,'','',0)); Hoping for some help! Thanks! Kashyap --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Javascript submit code with Ajax post
I'm not sure I'm getting to where your problem actually is because you haven't told us what is or is not happening. But... 0. I'm using Cake 1.2 so some things might be different 1. I don't see why you would want to redraw the tree, when I do this I set up a div below the tree that's a simple 'Updated' view rendered into it after the save completes. i.e. don't update the div with the tree in it but rather another div to indicate whether the save was successful or not. 1a. If you really want to redraw the tree the place to do it would be in the 'save' view (which you haven't included) 2. I see the ajax is supposed to submit with an interval which could work but you seem to be missing a 'before' option in the $ajax-submit that would call your saveMyTree_byForm(), it's just my preference but I tend to use a combination of onkeypress/onmouseout of the tree div to update the hidden field and only submit the form when a save button is pressed since the save button is outside the div the hidden field will be updated before the button is clicked, the onkeypress is in case the keyboard is used to submit i.e. the enter key. In this way I'm not unecessarily repeatedly posting to the server. So in the view: div .. onmouseout=document.getElementById('ModuleSavestring').value=treeObj?=$uniq;?.getSaveString(); onkeypress=(same as above). The tree/div div id=updateTree/div input type=hidden value= id=ModuleSavestring name=data[Savestring] / ?php echo $ajax-submit('Save Tree',array(update=updateTree.$uniq,url=updateTree)); ? 3. Maybe I'm being dof (Afrikaans word for dim) but in my controller side save method I parse the variable containing the hidden field and save the items one by one ala (this example only works to two levels of the menu): 4. For interest sake my initial menu is populated by model-findAllThreaded() function updateTree() { if (!empty($this-data)) { $nodes=split(',',$this-data['Savestring']); $vals=array(); foreach($nodes as $val) { $vals[]=split('-',$val); } $modids=$this-data['Module']; $modids[0]=0; $modules=array(); foreach($vals as $order=$record) { $modules[$order]['Module']['id']=$modids[$record[0]]; $modules[$order]['Module']['parent_id']=$modids[$record[1]]; $modules[$order]['Module']['order']=$order; } $this-data['Module']=$modules; foreach($modules as $module) $this-Module-save($module); $this-render('updatetree'); } } HTH Jeremy noso wrote: Hi everybody! I have a problem with posting a form. I use the tree Ajax component of DhtmlGoodies (http:// www.dhtmlgoodies.com/scripts/drag-drop-folder-tree/drag-drop-folder-tree.html) and I want to save it's structureString to the database. The problem is that it uses a javascript code to fill the hidden field in the form. !-- edit.thtml -- div id=menuTree_edit ul id=menuTreeContainer class=DHTMLSuite_tree li id=node_1 noDrag=truea href=#MenuBar/a ul TREE STRUCTURE /ul /li /ul /div ?= $ajax-form(array('action'=$html-url('save')));? ?= $html-hidden('menu_builder/saveString', array('id' = 'saveString', 'value' = 'none', 'size' = '40')) ? ?= $ajax-submit('save tree',array('url'='save', 'update'='menuTree_edit', 'frequency'='2')); ? function saveMyTree_byForm() { document.myForm.elements['saveString'].value = treeObj.getSaveString(); document.myForm.submit(); } ok then I have my controllerclass !-- menu_builder_controller.php -- class MenuBuilderController extends AppController { var $name = 'MenuBuilder'; var $helpers = array('Html', 'Javascript', 'Ajax'); //var $components = array('RequestHandler'); var $myMenuItems = array(); var $TreeData=array(); function index() { $this-myMenuItems = $this-MenuBuilder-findAll(); $this-set('menubuilder', $this-myMenuItems); if(isset($this-params['requested'])) { return $this-myMenuItems; } } function edit(){ $this-myMenuItems = $this-MenuBuilder-findAll(); $this-set('menubuilder', $this-myMenuItems); } function save(){ $success = true; $succesMessage = 'Menu update successfully'; if (empty($this-data)){ $success = false; $errorMessage = Error in menu
Re: Javascript submit code with Ajax post
Jeremy David Pointer wrote: I'm not sure I'm getting to where your problem actually is because you haven't told us what is or is not happening. But... 0. I'm using Cake 1.2 so some things might be different 1. I don't see why you would want to redraw the tree, when I do this I set up a div below the tree that's a simple 'Updated' view rendered into it after the save completes. i.e. don't update the div with the tree in it but rather another div to indicate whether the save was successful or not. 1a. If you really want to redraw the tree the place to do it would be in the 'save' view (which you haven't included) 2. I see the ajax is supposed to submit with an interval which could work but you seem to be missing a 'before' option in the $ajax-submit that would call your saveMyTree_byForm(), it's just my preference but I tend to use a combination of onkeypress/onmouseout of the tree div to update the hidden field and only submit the form when a save button is pressed since the save button is outside the div the hidden field will be updated before the button is clicked, the onkeypress is in case the keyboard is used to submit i.e. the enter key. In this way I'm not unecessarily repeatedly posting to the server. So in the view: div .. onmouseout=document.getElementById('ModuleSavestring').value=treeObj?=$uniq;?.getSaveString(); onkeypress=(same as above). The tree/div div id=updateTree/div input type=hidden value= id=ModuleSavestring name=data[Savestring] / ?php echo $ajax-submit('Save Tree',array(update=updateTree.$uniq,url=updateTree)); ? oops just ignore the .$uniq above the rest of the form that I'm took this from is complex with the possibility of multiple div's have the same name in a dhtml tabbed layout so nearly all my divs have .$uniq to uniquely identify them. 3. Maybe I'm being dof (Afrikaans word for dim) but in my controller side save method I parse the variable containing the hidden field and save the items one by one ala (this example only works to two levels of the menu): 4. For interest sake my initial menu is populated by model-findAllThreaded() function updateTree() { if (!empty($this-data)) { $nodes=split(',',$this-data['Savestring']); $vals=array(); foreach($nodes as $val) { $vals[]=split('-',$val); } $modids=$this-data['Module']; $modids[0]=0; $modules=array(); foreach($vals as $order=$record) { $modules[$order]['Module']['id']=$modids[$record[0]]; $modules[$order]['Module']['parent_id']=$modids[$record[1]]; $modules[$order]['Module']['order']=$order; } $this-data['Module']=$modules; foreach($modules as $module) $this-Module-save($module); $this-render('updatetree'); } } HTH Jeremy noso wrote: Hi everybody! I have a problem with posting a form. I use the tree Ajax component of DhtmlGoodies (http:// www.dhtmlgoodies.com/scripts/drag-drop-folder-tree/drag-drop-folder-tree.html) and I want to save it's structureString to the database. The problem is that it uses a javascript code to fill the hidden field in the form. !-- edit.thtml -- div id=menuTree_edit ul id=menuTreeContainer class=DHTMLSuite_tree li id=node_1 noDrag=truea href=#MenuBar/a ul TREE STRUCTURE /ul /li /ul /div ?= $ajax-form(array('action'=$html-url('save')));? ?= $html-hidden('menu_builder/saveString', array('id' = 'saveString', 'value' = 'none', 'size' = '40')) ? ?= $ajax-submit('save tree',array('url'='save', 'update'='menuTree_edit', 'frequency'='2')); ? function saveMyTree_byForm() { document.myForm.elements['saveString'].value = treeObj.getSaveString(); document.myForm.submit(); } ok then I have my controllerclass !-- menu_builder_controller.php -- class MenuBuilderController extends AppController { var $name = 'MenuBuilder'; var $helpers = array('Html', 'Javascript', 'Ajax'); //var $components = array('RequestHandler'); var $myMenuItems = array(); var $TreeData=array(); function index() { $this-myMenuItems = $this-MenuBuilder-findAll(); $this-set('menubuilder', $this-myMenuItems); if(isset($this-params['requested'])) { return $this-myMenuItems; } } function edit(){ $this-myMenuItems = $this-MenuBuilder-findAll
Re: How to update a View-DIV and an element at once with Ajax-Submit-Button?
Simple answer is : it is impossible to update multiple divs with different content with one call to a controller in the way I think you are thing (I have two possible solutions I'll get to shortly) Think about the flow: ajax-submit requests a document or portion of page from the server what is returned is one document, the update option tells which div to put that document into. What I think you want is to update an additional div with some other content if I'm right then: Solution 1: The controller action returns one document containing both divs Use CSS positioning to define where update1 and update2 are on the page if they aren't adjacent. If you have: div id=container div id=update1 Content1 /div div id=update2 /div /div then ajax-submit should update container and the controller action should render a view div id=update1div id=update2. Solution2: ajax submit updates one of the divs and use the before or after options of the ajax-submit to call an additional javascript function that updates the other one. I don't want to double post but this same answer applies to the Thread with subject AJAX Update DIVs in two layouts in fact apart from the wording the question is precisely the same one. Regards Jeremy Now would some kind soul please answer my question from a few days ago ;-) Dakapo wrote: Hello! Since hours I'm trying to update two divs after a submit via ajax. The first layer contains a view-file (edit.thtml) The second one should get rendered from an element. But only the edit.thtml gets updated. I must misunderstand something with the Cake-Ajax-Handling but I don't know what. I would be so thankful if somebody could help me. You can find the code under http://bin.cakephp.org/view/648753697 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to update a View-DIV and an element at once with Ajax-Submit-Button?
Chris Hartjes wrote: On 6/21/07, Jeremy David Pointer [EMAIL PROTECTED] wrote: Simple answer is : it is impossible to update multiple divs with different content with one call to a controller in the way I think you are thing (I have two possible solutions I'll get to shortly) I'm thinking the problem is with the helper, as I've written Javascript code by hand to do exactly what you are proposing many times. Yes me too I've done 'AJAX' using frames and top.framename.location (sure it isn't as flexible as updating a DIV but with the right frames layout it worked wonderfully). Actually I think the problem is more a case of one understanding the limitation of the helper and working around it - A good workman never blames the tools :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: AJAX Update DIVs in two layouts
See my reply in the topic: How to update a View-DIV and an element at once with Ajax-Submit-Button? In your case solution 2 might be the better option or you could just write the js manually to update both divs i.e. something of the order: input onclick=update2divs(parameters) And js: function update2divs(parameters) { ajaxupdate('div1','url'); ajaxupdate('div2','url2'); } Or read more on js and AJAX and you'll find the possibilities are numerous. Now if only I could my brain out of it's writers block to solve my own problem. Jeremy [EMAIL PROTECTED] wrote: Sorry, I wasn't very clear. I actually do have the DIVs in elements and render them within my layouts. But I still may be doing it incorrectly. Basically, I have a special statistics DIV that needs to update with statistics and possibly other bits of data and I'd like to position it absolutely to the entire application so I've rendered it in /layout/ default.ctp. But the rest of the application is in a container and is in it's /views/controller/action.ctp layout. So I'd like to have a link that updates the application layout but then updates the little statistics DIV in the default.ctp layout. I could put it in the /views/controller/action.ctp and then put a negative CSS top and left value on it to move it to the corner but I wanted to inquire if there was a way to do this with the Ajax helper and keep it in the default.ctp then just update it. I thought perhaps in the controller I could do: $this-render(array('layout1','default'), 'ajax'); Thanks for your help! Wilson On Jun 21, 1:48 pm, Chris Hartjes [EMAIL PROTECTED] wrote: On 6/21/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Thanks Chris. Yes, I've looked throughout, but the only answers I've found pertain to changing DIVs in one layout. Have a nice day. Why are you trying to render two layouts at the same time? And why would you put dynamic code in your layout when it should be in an element? -- Chris Hartjes Senior Developer Cake Development Corporation My motto for 2007: Just build it, damnit! @TheBallpark -http://www.littlehart.net/attheballpark @TheKeyboard -http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to update a View-DIV and an element at once with Ajax-Submit-Button?
Chris Hartjes wrote: On 6/21/07, Jeremy David Pointer [EMAIL PROTECTED] wrote: Yes me too I've done 'AJAX' using frames and top.framename.location (sure it isn't as flexible as updating a DIV but with the right frames layout it worked wonderfully). Actually I think the problem is more a case of one understanding the limitation of the helper and working around it - A good workman never blames the tools :-) Oh please. That's just nonsense. A good workman knows when his tools are crummy and when he has to hand-craft things. It's still not the tools fault if one decides to try to use a tool for a job it wasn't made for. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to update a View-DIV and an element at once with Ajax-Submit-Button?
Chris Hartjes wrote: On 6/21/07, Jeremy David Pointer [EMAIL PROTECTED] wrote: It's still not the tools fault if one decides to try to use a tool for a job it wasn't made for. Okay, we're getting into philosophical debates here. My only point is that if the helper won't do what you want you have two choices: 1) figure out how to change the helper to make it do what you want 2) just write the damn code by hand Me, being lazy and pragmatic I usually go with option #2 and hope I get a chance to go back and work on option #1. rofl I agree 100% with that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
One to many forms with ajax
It's always boggled me why there are lots of many to many relationship examples but hardly any one to many examples. My major stumbling block here is how to set up the form and controller to save the detail lines when 'Save' is clicked and how to manage the detail table when Add/Del are clicked. Is there an example/sample/tutorial someone can point me to, of one to many forms with an editable grid out there, i.e. something like an invoice/order form such as below the ||'s indicate editable fields and 's buttons/links. | Customer Choosing combo/Auto complete |v| Address1 Address2 Address3 Item Code Qty Unit Price Total | |||| || | Del | |||| || | Del | |||| || | Del Add -- SubTotal Tax Total Save Any other ideas/ you're an idiot's etc are welcome so long as they are helpful. Regards Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One to many forms with ajax
In case it makes a difference I'm using CakePHP 1.2 Jeremy David Pointer wrote: It's always boggled me why there are lots of many to many relationship examples but hardly any one to many examples. My major stumbling block here is how to set up the form and controller to save the detail lines when 'Save' is clicked and how to manage the detail table when Add/Del are clicked. Is there an example/sample/tutorial someone can point me to, of one to many forms with an editable grid out there, i.e. something like an invoice/order form such as below the ||'s indicate editable fields and 's buttons/links. | Customer Choosing combo/Auto complete |v| Address1 Address2 Address3 Item Code Qty Unit Price Total | |||| || | Del | |||| || | Del | |||| || | Del Add -- SubTotal Tax Total Save Any other ideas/ you're an idiot's etc are welcome so long as they are helpful. Regards Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: FCKEditor Problem
Try something like the below : The key here is the 'before' section in the ajax submit, FCKEditor attaches itself to the forms submit action but that isn't used with an ajax submit, so you have to call the code to update the form field manually. I found this methodology somewhere in the FCKEditor faq/documentation/user group. echo $ajax-submit('Save',array(update=updatediv_.$uniq, class=panelButt, 'indicator' = 'spinner_'.$uniq, 'before' = for (instance in FCKeditorAPI.__Instances) { field_name = instance.toString(); if (field_name.indexOf('.$uniq.')=0) { field_value = FCKeditorAPI.GetInstance(field_name).GetXHTML(); $('ni.$uniq.').getInputs(null,'data[Newsitem][text]') [0].value = field_value; } } ) ); On Tuesday 22 May 2007 09:52, [EMAIL PROTECTED] wrote: Can anyone help me to resolve this problem? Or can anyone suggests me a alternative method? Many thanks On 21 Mag, 12:15, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Instead if I used the $html-submit it works fine. On 21 Mag, 11:58, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have to useFCKEditorto edit posts in my application. I use a form with a textarea where I loadFCKEditor. The form is submitted with $ajax-submit. Myproblemis that the modifies that I do withFCKEditoris not passed to the controller. How and where must I use the htmlspecialchars to get the right result? Many Thanks Marco- Nascondi testo tra virgolette - - Mostra testo tra virgolette - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to implement code to download files
On Monday 07 May 2007 07:50, Anil wrote: Hi, I need the help to implement code for downloading files. If you know how to do that, please do me the favour. umm just provide a href. to th file locations. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: caching actions + different user
On Saturday 05 May 2007 08:18, bingo wrote: hi bakers, I am trying to speed up things on my website by using caching. I have an action that displays all the articles that a user has in his library based on user id. I am not sure how to cache this action so that cache are stored for each user. Regards, Ritesh Maybe you did this already, but just a general tip that makes a huge difference in speed with related tables, make sure you have the relationship fields indexed. Regards Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: $number-precission not working in controller
Look at phps sprintf function? Joshua McFarren wrote: Ok, ok, I looked again at the manual and helpers are mean to provide functions that are commonly needed in views etc. So I guess this was stupid not easy. Also I misspelled precision in the subject AND my corner cases are not fully checked ($,100,000.0) with that regex! Still... does anyone have a suggestion for a way to make sure totaldue is rendered in two decimal places? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---