Re: RequestHandler->isAjax not returning expected data
doublesswizz, Hm that is a strange problem. Although I can't really tell you what is going wrong, I would caution you about using the "fix" you have in place. All it would take for a user to fake an ajax request would to get a simple tool like firebug and set what url the ajax post or get request is calling, and put that into the browser along with the variable you have included includes. On Aug 7, 8:20 pm, doubleswizz <[EMAIL PROTECTED]> wrote: > Although I'm not sure what is causing the above behavior, I do have a > workaround for it. Whenever I call the controller action via ajax, I > append a get variable onto the URL. Then, I just check for that > variable to determine if the action was called via ajax or not. --~--~-~--~~~---~--~~ 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: Linking a HABTM Association to extra data beside the tag?
rtconner, Thank you for the reply. Now I'm not sure you understand me correctly, or I am not sure I understand myself :P. I am aware of this method, filtering a HABTM relationship creating a "dummy" model in the join table. I already have something like this and it works perfectly. What I don't understand what you are saying is, what I tables should be made? Are you saying that all is necessary is the join table FansUsers and then in there do something like User.id, and Fan.id, and The FansUsers each FansUser belongs to one user? I don't understand how that would work because If I have user A, and he has fans B and C, then I want fans B and C to belongs to their corresponding information, so when I pull up the fans for user A, I get user B and user C's information. So if I understand you correctly, I will only need one extra table, and will just need to fabricate a join table everytime I wish to find the fans of a user? Thank you, Jim On Aug 1, 8:59 am, rtconner <[EMAIL PROTECTED]> wrote: > If I'm catching what you are doing... You have to create a FansUser > model and add some relationships to it. > > http://groups.google.com/group/cake-php/browse_frm/thread/f23b1825050...http://groups.google.com/group/cake-php/browse_frm/thread/8cbf01f7a9a... > > I think.. this is what you want. I could be wrong though. > > On Aug 1, 9:47 am, Jim Newfer <[EMAIL PROTECTED]> wrote: > > > Anyone? Sorry, I am just stuck. If there was some way in cake to > > specify an alternative key it is searching for in the foreign table, I > > think that may solve my problem. > > Thanks. > > > Jim. > > > On Jul 31, 1:55 pm, Jim Newfer <[EMAIL PROTECTED]> wrote: > > > > Hello everyone, > > > > Last resort post, I am stuck. What I have done is create a "friends" > > > system in my app. Although it is mildly tricky because the friends are > > > the same thing as users, just using an alias. > > > > My tables look like this right now (only relevant information shown): > > > > Users: > > > Id > > > > Fans_Users: > > > fan_id > > > user_id > > > > Fans: > > > id > > > fans_info > > > > The fan is just an alias for another user. I have the HABTM > > > association set up fine and dandy. But what I cannot seem to get to > > > work no matter what I try, is get the user infomation to be be pulled > > > up with that fan. For example, User 67 has two fans, users 45 and > > > users 46. Not when I query for User 67, his two fans are shown, users > > > 45 and 46. BUT, I want users 45 and users 46 information to be shown > > > as well. I have tried all sorts of combinations of hasOne/belongsTo in > > > the fans table to get the fan to link to some user info. Even tried > > > adding a fan_id to the user table, (which is the same thing as their > > > id) And linking it to that. Problem is, it is matching the Fan.id to > > > the fan.user_id which is obviously a problem. I was thinking if I > > > could somehow modify the primary key it is searching for in the local > > > table, it could work (instead of matching the Fan.id to the User.id, > > > match the Fan.fan_id to the User.id) > > > > I am really stuck here, has anyone attempting anything similar? > > > > Thanks. > > > > Jim --~--~-~--~~~---~--~~ 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: Linking a HABTM Association to extra data beside the tag?
Anyone? Sorry, I am just stuck. If there was some way in cake to specify an alternative key it is searching for in the foreign table, I think that may solve my problem. Thanks. Jim. On Jul 31, 1:55 pm, Jim Newfer <[EMAIL PROTECTED]> wrote: > Hello everyone, > > Last resort post, I am stuck. What I have done is create a "friends" > system in my app. Although it is mildly tricky because the friends are > the same thing as users, just using an alias. > > My tables look like this right now (only relevant information shown): > > Users: > Id > > Fans_Users: > fan_id > user_id > > Fans: > id > fans_info > > The fan is just an alias for another user. I have the HABTM > association set up fine and dandy. But what I cannot seem to get to > work no matter what I try, is get the user infomation to be be pulled > up with that fan. For example, User 67 has two fans, users 45 and > users 46. Not when I query for User 67, his two fans are shown, users > 45 and 46. BUT, I want users 45 and users 46 information to be shown > as well. I have tried all sorts of combinations of hasOne/belongsTo in > the fans table to get the fan to link to some user info. Even tried > adding a fan_id to the user table, (which is the same thing as their > id) And linking it to that. Problem is, it is matching the Fan.id to > the fan.user_id which is obviously a problem. I was thinking if I > could somehow modify the primary key it is searching for in the local > table, it could work (instead of matching the Fan.id to the User.id, > match the Fan.fan_id to the User.id) > > I am really stuck here, has anyone attempting anything similar? > > Thanks. > > Jim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Linking a HABTM Association to extra data beside the tag?
Hello everyone, Last resort post, I am stuck. What I have done is create a "friends" system in my app. Although it is mildly tricky because the friends are the same thing as users, just using an alias. My tables look like this right now (only relevant information shown): Users: Id Fans_Users: fan_id user_id Fans: id fans_info The fan is just an alias for another user. I have the HABTM association set up fine and dandy. But what I cannot seem to get to work no matter what I try, is get the user infomation to be be pulled up with that fan. For example, User 67 has two fans, users 45 and users 46. Not when I query for User 67, his two fans are shown, users 45 and 46. BUT, I want users 45 and users 46 information to be shown as well. I have tried all sorts of combinations of hasOne/belongsTo in the fans table to get the fan to link to some user info. Even tried adding a fan_id to the user table, (which is the same thing as their id) And linking it to that. Problem is, it is matching the Fan.id to the fan.user_id which is obviously a problem. I was thinking if I could somehow modify the primary key it is searching for in the local table, it could work (instead of matching the Fan.id to the User.id, match the Fan.fan_id to the User.id) I am really stuck here, has anyone attempting anything similar? Thanks. Jim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Updating a via ajax, although getLastInsertId() or $this->Comment->id does not retrieve the last inserted record.. why?
Sorry guys I just cannot figure this one out. I creating an ajax comment system that does not have to reload all of the comments (i.e. foreach loop getting all of the comments) So what I have done is create a dummy that the comment will be loaded into, and when the page is reloaded, it will automatically be placed with the other comments as usual. The problem is, in my ajax function, it won't search, find, or in any way see $this->Comment->id or $this->Comment- >getLastInsertId() for anything after the save.And I do have the debug level set to 2, and it seems like a query is never being run, except for where i will explain below The controller looks like so... function viewstuff(){ $this->layout = 'ajax'; if($this->Comment->save($this->data){ /*Here is everything i have tried, corresponding with their sql queries it runs */ // $this->set('comment' ,$this->Comment->findById($this->Comment- >getLastInsertId())); //SELECT `Comment`.`id`, `Comment`.`body`, `Comment`.`user_id`, `Comment`.`story_id` FROM `comments` AS `Comment` WHERE `Comment`.`id` IS NULL LIMIT 1, now I have no idea why it sets the id to IS NULL, my guess is that this means the ID has not been set yet, but i don't understand this because I have only called upon this function unless I have saved, meaning the id SHOULD be set //here is everything i have tried, that does not work //$id = $this->Comment->id ; // $this->set('comment', $this->Comment->read($id)); //returns a sql query that is blank $tmp_id = $this->Comment->id; $this->set('comment', $this->Comment->findAll("id = $tmp_id")); //this returns a sql error... //it queries like this, not querying for the id SELECT `Comment`.`id`, `Comment`.`body`, `Comment`.`user_id`, `Comment`.`story_id` FROM `comments` AS `Comment` WHERE id = //then returns the error //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 '' at line 1 ***I have tried these and many more, and am begging for assistance :P Here is my corresponding view as well, //this is all it is because i am just testing right now **And I should add I am using jquery to call upon this function (and the data is saved successfully btw) // wait for the DOM to be loaded $(document).ready(function() { // bind 'myForm' and provide a simple callback function $('#myform').ajaxForm(function() { $("#newcomment").load('/stories/viewstuff'); // $("#newcomment").load('/stories/lastcomment'); }); }); And just a side note as well, I can set ANY VARIABLE in the controller above that I am attempting to call the $this-.Comment->Id or $this- >Comment->getLastInsertId(); and it will UPDATE JUST FINE. THIS IS ONLY A PROBLEM WITH $THIS->COMMENT->ID or $THIS->COMMENT- >GETLASTINSERTID() NOT BEING SET. Everything else, all variables, queries, etc. in the controller are set just fine. I am wondering if for some reason the getLastInsertId or id is not being set right away for some reason? Any advice is GREATLY appreciated. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Autocomplete options in 1.2 messes up my field.
Hey, Well I have been using an autocomplete field for quite some time and everything has worked fine. Although I just tried to add this onto the end 'afterUpdateElement' => 'getSelectionId') autocomplete('User.school_id', '/users/ autocomplete', array('afterUpdateElement' => 'getSelectionId')); ?> /then i have this function to alert the user of the selection id function getSelectionId(text, li) { alert (li.id); } This is a very strange problem, everything works fine until I add that last bit, and a small grey line appears below the autocomplete field. I'm sure there is a simple fix to this, and my autocomplete view looks like this btw. I am trying to automatically input the ID of the selecton in the form. ' .''.$school['School']['city'].', ' . $school['School']['state']. ''; ?> --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Struggling with creating a function and search an array then outputting data based upon results...
I have been trying to figure this out for the past 2 hours and to no avail. :/ So any advice is GREATLY appreciated. Ok, I have an array that returns data like this (see array below) The array[0] contains all the votes for one story as well as information that pertains to that vote, and the array[1] contains vote information for another story. What I need to do is check is a user_id stored in a session, is in the array, and then create a boolean array from that. For example, here I want to check if the user_id is featured in the first set of data, let's say my user_id is 74. Ok, so it is in the first set of data, so we set the boolean variable to true. Next I need to search the second data field for my user_id, 73. It is not featured here so the value in my array is set to 0. I need an array that returns values either 1, for true, your user_id was found in the table, or false, for your user_id was not featured in the table. They need to be in order of the story too. I'm having trouble one comparing the two variables against eachother, since the array is very deep, and two, creating the array on the fly. Any suggestions are recieved with open arms! Thanks for looking ! Array ( [0] => Array ( [0] => Array ( [id] => 5 [story_id] => 122 [user_id] => 74 ) [1] => Array ( [id] => 6 [story_id] => 122 [user_id] => 74 ) ) [1] => Array ( [0] => Array ( [id] => 7 [story_id] => 123 [user_id] => 74 ) [1] => Array ( [id] => 8 [story_id] => 123 [user_id] => 74 ) [2] => Array ( [id] => 9 [story_id] => 123 [user_id] => 74 ) ) ) [1] => Array ( * => Array ( [id] => 7 [story_id] => 123 [user_id] => 45 [Story] => storythree ) ) ) P.S. The reason I am trying to return a boolean array is because they will set a value in the view in a div tag for the class, like so --~--~-~--~~~---~--~~ 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: Passing data back from jquery to a controller?
On Jul 6, 9:01 am, Jim Newfer <[EMAIL PROTECTED]> wrote: > hey guys, > > Sorry but I just cannot get my head around this one. I am trying to > pass back a value from jquery to my controller. Everything runs ok, > except my controller does not get or doesn't recognize the value I am > passing it via jquery. > > //here is my javascript > > $(document).ready(function(){ > $("#votebox").click(function(){ > > $(this).load("/stories/vote/" + $idof); > > }) > > //Here I have already checked, $idof contains a value of 3, so should > the controller that is being requested look like /stories/vote/3 ? Or > am I missing something. I already asked the guys over at jquery and > they said syntactically correct, and that it is something wrong on my > end, so it must be cake. > > Any help is greatly appreciated. > > My function looks like this btw, and accepts an id, which it is not > recognized > > function vote($id){ > $this->Story->id = $id; > $count = $this->Story->field('Story.agree'); > $newcount = $count + 1; > $this->data['agree'] = $newcount; > $this->Story->save($this->data); > > } > > Thanks again SOLVED SOLVED SOLVED SOLVED --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Passing data back from jquery to a controller?
hey guys, Sorry but I just cannot get my head around this one. I am trying to pass back a value from jquery to my controller. Everything runs ok, except my controller does not get or doesn't recognize the value I am passing it via jquery. //here is my javascript $(document).ready(function(){ $("#votebox").click(function(){ $(this).load("/stories/vote/" + $idof); }) //Here I have already checked, $idof contains a value of 3, so should the controller that is being requested look like /stories/vote/3 ? Or am I missing something. I already asked the guys over at jquery and they said syntactically correct, and that it is something wrong on my end, so it must be cake. Any help is greatly appreciated. My function looks like this btw, and accepts an id, which it is not recognized function vote($id){ $this->Story->id = $id; $count = $this->Story->field('Story.agree'); $newcount = $count + 1; $this->data['agree'] = $newcount; $this->Story->save($this->data); } Thanks again --~--~-~--~~~---~--~~ 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: Using jquery's Ajax functions in tandem with CakePHP...
Gremlin, thank you so much for your reply! So far it isn't working but in the top of my javascript I have a requestAction, and in my controller I set something like this if(isset($this->params['requested'])) { return array('stories' => $getstories, 'school' => $schoolname); That is all I should need to do to have jquery be able to access my models right ? Thanks for any more advice from anyone. On Jul 2, 10:24 pm, gremlin <[EMAIL PROTECTED]> wrote: > You can call a script the same way, just use $( "#quote p" ).load( "/ > contoller/action" ); > > Make sure your controller handlesajaxrequests. If you don't know > what that means look up requestAction or parseExtensions in the > groups. > > On Jul 2, 10:12 pm, Jim Newfer <[EMAIL PROTECTED]> wrote: > > > I have been usingjquery, which is great btw, with cakephp for a > > couple of weeks now. I love it to say the least. I haven't really > > dealt withajaxvery much, but I have done some basic things with it, > > and PHP outside of cake. Needless to say, when it comes time to use > >jquery'sajaxfunctionality with cake, I am completely and totally > > lost. > > > I trying to get this EXTREMELY simple tutorial to work with cakephp > > for about the past 3 hours, and just cannot seem to figure it out. > > >http://www.sitepoint.com/article/ajax-jquery > > > I think it make have something to do with this line injquery, where > > it calls for an outside script. > > > $("#quote p").load("script.php"); > > > I was wondering is there some way to instead, call upon a specific > > controller? Or passjqueryinformation? > > > Obviously I do not want to include a separate script because that > > would be an unnecessary hassle. I am just looking for pointers/tips on > > how to useajax'sfunctionality with cake, because I cannot seem to > > find any good tutorials anywhere on incorporatingjqueryinto cake. > > > Any guidance is GREATLY appreciated. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Using jquery's Ajax functions in tandem with CakePHP...
I have been using jquery, which is great btw, with cakephp for a couple of weeks now. I love it to say the least. I haven't really dealt with ajax very much, but I have done some basic things with it, and PHP outside of cake. Needless to say, when it comes time to use jquery's ajax functionality with cake, I am completely and totally lost. I trying to get this EXTREMELY simple tutorial to work with cakephp for about the past 3 hours, and just cannot seem to figure it out. http://www.sitepoint.com/article/ajax-jquery I think it make have something to do with this line in jquery, where it calls for an outside script. $("#quote p").load("script.php"); I was wondering is there some way to instead, call upon a specific controller? Or pass jquery information? Obviously I do not want to include a separate script because that would be an unnecessary hassle. I am just looking for pointers/tips on how to use ajax's functionality with cake, because I cannot seem to find any good tutorials anywhere on incorporating jquery into cake. Any guidance is GREATLY appreciated. --~--~-~--~~~---~--~~ 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: A question about integrating jquery in cakephp?
Alright, I got it to work, when I removed the line of code from my default layout, $scripts_for_layout. Can someone please tell me what $scripts_for_layout is used for? Thank you. On Jul 1, 7:51 pm, Geoff Ford <[EMAIL PROTECTED]> wrote: > All javascript files need to be placed in app/webroot/js and you need > to include the javascript helper. > > http://manual.cakephp.org/chapter/helpersabout 3/4 down is the > javascript helper documentation > > Geoff > --http://lemoncake.wordpress.com > > On Jul 2, 10:28 am, Jim Newfer <[EMAIL PROTECTED]> wrote: > > > I have been using jquery for about a month now, and I love it to say > > that least. Although, I cannot seem to figure out the best way to > > incorporate it into my cakephp project, or even to incorporate it at > > all! > > > When I used jquery before, I just loaded the jquery.js library in the > > header, and then wrote the javascript in the header in between the > > tags. > > > So I have tried to duplicate this in more ways than one, and none of > > them have worked. I have tried in my default layout, using > > $javascript->link('jquery', false) in the header of my default layout > > trying to > > > get it to work, and then placing $scripts_for_layout in content area > > of the default layout. I have tried including both in the view file, > > and combinations of all of these. > > > Could someone just please explain how and where the files need to go > > when using jquery with cakephp ? Thank you. --~--~-~--~~~---~--~~ 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: A question about integrating jquery in cakephp?
Geoff, Yes, am I aware of this, and this is what I have done, not only have I included the javascript helpers in my controllers, I also included them into my AppController so my layout would have access to the javascript helper when calling $this->javascript('file') in the header of my default layout. Strange. On Jul 1, 7:51 pm, Geoff Ford <[EMAIL PROTECTED]> wrote: > All javascript files need to be placed in app/webroot/js and you need > to include the javascript helper. > > http://manual.cakephp.org/chapter/helpersabout 3/4 down is the > javascript helper documentation > > Geoff > --http://lemoncake.wordpress.com > > On Jul 2, 10:28 am, Jim Newfer <[EMAIL PROTECTED]> wrote: > > > I have been using jquery for about a month now, and I love it to say > > that least. Although, I cannot seem to figure out the best way to > > incorporate it into my cakephp project, or even to incorporate it at > > all! > > > When I used jquery before, I just loaded the jquery.js library in the > > header, and then wrote the javascript in the header in between the > > tags. > > > So I have tried to duplicate this in more ways than one, and none of > > them have worked. I have tried in my default layout, using > > $javascript->link('jquery', false) in the header of my default layout > > trying to > > > get it to work, and then placing $scripts_for_layout in content area > > of the default layout. I have tried including both in the view file, > > and combinations of all of these. > > > Could someone just please explain how and where the files need to go > > when using jquery with cakephp ? Thank you. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
A question about integrating jquery in cakephp?
I have been using jquery for about a month now, and I love it to say that least. Although, I cannot seem to figure out the best way to incorporate it into my cakephp project, or even to incorporate it at all! When I used jquery before, I just loaded the jquery.js library in the header, and then wrote the javascript in the header in between the tags. So I have tried to duplicate this in more ways than one, and none of them have worked. I have tried in my default layout, using $javascript- >link('jquery', false) in the header of my default layout trying to get it to work, and then placing $scripts_for_layout in content area of the default layout. I have tried including both in the view file, and combinations of all of these. Could someone just please explain how and where the files need to go when using jquery with cakephp ? Thank you. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---