Re: Problem with transaction in version 2.0
It seems that you're calling transactions methods from the model while you should call them from the datasource instance. Try something like this. $datasource = $this-StadiobingoBet-getDataSource(); $datasource-begin($this-StadiobingoBet); if($this-StadiobingoBet-saveAll($yourdata, array('validate' = false)) { $datasource-commit($this-StadiobingoBet); } else { $datasource-rollback($this-StadiobingoBet); } On Dec 20, 1:48 pm, socrates socrates.alessan...@gmail.com wrote: No in fact it does not solve my problem, but maybe i don't understand very well. This is my piece of code: $this-StadiobingoBet-query('SET AUTOCOMMIT = OFF'); debug($this-StadiobingoBet-begin()); if (!$this-StadiobingoBet-saveAll(null, array('atomic' = true, 'validate' = false))) { $this-StadiobingoBet-commit();} else { $this-StadiobingoBet-rollback(); } If the query of save associated goes well, it have to rollback, but it does not. -- 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: virtualfields + description cache
Did you try to set cacheSources to false in the model, as it has cacheSources property? On Dec 19, 5:48 pm, Janos Csikos ja...@csikos.co.uk wrote: Hi All, I have a problem with the description caching in datasource (CakePHP 1.3.12). Or maybe with my solution. My problem: I need to count a value based on other fields in the same table. My solution: I used the virtual fields for this. So let MySQL to work rather than count it in PHP. It is working and fine. I love the clean results. One of a new feature should give an option to the users to choose between the columns that used in the virtual fields. I've sorted this out, but later realised the description caching doesn't helps. So decided to turn of the description cache in the datasource (DataSource::__cacheDescription()), which dependent on the DataSource::cacheSources property (should be false). I expected the following code to do that in my actual model: function __construct($id=false,$table=null,$ds=null) { parent::__construct($id,$table,$ds); $dbo = $this-getDataSource(); $dbo-cacheSources = false; $dbo-cacheMethods = false; } Actually this is not working. What I did wrong? Any comment could be helpful! Any other way to solve my problem? Many thanks, Janos -- 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: saveField() causes a SELECT COUNT(*)
I think it's to be sure that the record actually exists and it's updated. If you make mysql update call on a non-existent record you won't get an error, so the saveField() would return true when it should return false. By executing the COUNT statement saveField() can return false if the record doesn't exist On Jun 6, 8:28 pm, Jake Moilanen moila...@gmail.com wrote: I have a very expensive background analytic process which is hammering my database and I am wanting to reduce the unnecessary database calls where ever I can. I have a general log on my database and I noticed whenever the code does a saveField() that first it tries getting the count on a primary key (which should always be 1): SELECT COUNT(*) AS `count` FROM `page_instances` AS `PageInstance` WHERE `PageInstance`.`id` = 3214334 UPDATE `page_instances` SET `visible` = '0' WHERE `page_instances`.`id` = 3214334 I can do the UPDATE manually in my model and it avoids this SELECT COUNT(*), but I was unsure if getting the count was for good reason. Using version 1.2.6. Thanks, Jake 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
Re: I'm trying to make a good find with three HABTM models
You can try Containable behavior. In models put var $actsAs = array('Containable'); and then in the controller $this-Project-find('all', array('contain' = array('Group' = array('User'; you can find out more about the Containable behavior in the cook book http://book.cakephp.org/view/1323/Containable On Jun 7, 2:54 pm, DrLaban jbh...@gmail.com wrote: My setup is pretty straightforward; User HABTM Group Group HABTM Project Project HABTM User I would like to produce a find-query that takes a single project-id and builds a hierarchic contact list, in which the users belong to their respective group(s). Something along these lines: [Project 1] [Group 1] [User 1] [User 5] [Group 2] [User 1] [User 2] [User 3] [Group 4] [User 3] [User 4] ... Is this possible and if so, how? All I've been able to produce is something of a flat structure where I can't match the user to a group; [Project 1] [User 1] [User 3] [User 4] [User 6] [Group 1] [Group 3] [Group 4] This is produced when I do; $this-Project-find('all'); 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
Re: I'm trying to make a good find with three HABTM models
The easiest way that comes to mine mind would be to get the ids of the projects you are involved at first and then pass those as condition in the before mentioned find call. Something like... $this-loadModel('ProjectsUser'); $ids = $this-ProjectsUser-find('list', array('conditions' = array('ProjectsUser.user_id = $yourId))); $projects = $this-Project-find('all', array( 'contain' = array( 'Group' = array('User') ), 'conditions = array('Project.id' = array_keys($ids)) )); there are probably other ways of doing this, but I would have to think and test before I recommend them. :) Cheers On Jun 7, 9:03 pm, DrLaban jbh...@gmail.com wrote: Oooh! That's pretty awesome, and it seems to work like a charm, thanks! Just one more question on this subject. This involves a bit more trickery I believe; I'd also like to be able to view all the Groups/Users for all the projects I'm involved at. This would look something like [Project 1] [Group 1] [User 2] [User 3] [User 4] [Group 10] [User 1] [User 3] [Project 2] [Group 25] [User 1] [User 3] [User 7] Now, the information about what projects I'm involved at is stored in projects_users. I guess I somehow have to use this information to be able to present it in the above described way? Otherwise I'm not sure as to how I could first filter out all the projects I'm involved with and then go hunt for the groups and users. Any insights on this matter is really appreciated. Thank you in advance! On Jun 7, 3:26 pm, vekija vedran.konto...@gmail.com wrote: You can try Containable behavior. In models put var $actsAs = array('Containable'); and then in the controller $this-Project-find('all', array('contain' = array('Group' = array('User'; you can find out more about the Containable behavior in the cook bookhttp://book.cakephp.org/view/1323/Containable On Jun 7, 2:54 pm, DrLaban jbh...@gmail.com wrote: My setup is pretty straightforward; User HABTM Group Group HABTM Project Project HABTM User I would like to produce a find-query that takes a single project-id and builds a hierarchic contact list, in which the users belong to their respective group(s). Something along these lines: [Project 1] [Group 1] [User 1] [User 5] [Group 2] [User 1] [User 2] [User 3] [Group 4] [User 3] [User 4] ... Is this possible and if so, how? All I've been able to produce is something of a flat structure where I can't match the user to a group; [Project 1] [User 1] [User 3] [User 4] [User 6] [Group 1] [Group 3] [Group 4] This is produced when I do; $this-Project-find('all'); 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
Re: Model with two belongsTo associations
It should work with Containable behavior. for example $categories = $this-Category-find('all', array('contain' = array('Item' = array('Label'; should return an array like: Category 1 Item 1 Label 1 Item 2 Label 2 Category 2 Item 3 Label 3 On Jun 7, 10:17 pm, bmcelhany bmcelh...@gmail.com wrote: Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So, Categories and Labels are completely unrelated, but the Item belongs to both of them. Now, in my Category view (and Category controller) I want to display the Cateogry info (obviously) and a list of all of that Category's Items. So far so good. However, what I'd also like is, for each Item that is listed, to display that Item's associated Label. Something like: Category 1 Item 1 (Label for Item 1) Item 2 (Label for Item 2) Category 2 Item 3 (Label for Item 3) I've tried different combinations of recursion (on all three models) and I've tried using the containable behavior but I can't seem to get the Label data to be included. The label data appears fine when I'm working with the Item views and controller, but when I'm up one level higher (in the context of a Category) they aren't attached. Any thoughts on 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
Re: Optional Validation
just add 'allowEmpty' = true to the 'state' array On Jun 7, 10:51 pm, naidim nai...@gmail.com wrote: How do you set Cake validation to only verify the rules IF there is content. If the field is left blank (optional field), skip validation. e.g. var $validate = array( 'state' = array( 'rule' = '/^[a-z]{2}$/i', // 2 letters 'message' = 'You must enter a valid state.' ) ); This always runs, even if the content of the field is left blank. I want it to skip validation if the field is left blank. 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
Re: Using Javascript-link Inside An Element
you have to echo those :) echo $javascript-link('mootools-for-dropdown', false); On Jun 7, 8:43 pm, Dima dmitriy.pind...@gmail.com wrote: I'm pretty new to CakePHP so it is likely that my issue is rather simple to fix. I have a custom element which I created called nav_menu.cpt. I call this element from default.cpt using: ?php echo $this-element('nav_menu'); ? For my element to work properly, I need to import 3x .js files and 1x .css file; I have placed these files in /webroot/js/ and /webroot/ css/ respectively and am attempting to call them inside the element like so: ?php $javascript-link('mootools-for-dropdown', false); $javascript-link('UvumiDropdown-compressed', false); $javascript-link('nav_menu', false); $html-css('uvumi-dropdown'); ? However, when the page loads and I check page source, it doesn't include these files in the header. I've also tried calling this following line in default.cpt with no success: ?php e($scripts_for_layout); ? What am I doing wrong?? Thanks, Dima 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
Re: Model with two belongsTo associations
hmm, not sure... you could always write your own query or/and implement caching, depends on the load on you application. On Jun 7, 10:42 pm, bmcelhany bmcelh...@gmail.com wrote: Ah, I didn't realize you could nest models within a single contain...good to know! So, I gave that a shot and it works perfectly...just what I need! One additional question: I notice that for each Item there is an additional query performed to get that Item's Label information. I'm not dealing with a huge amount of data so I'm not too concerned, but it would be nice if I could maybe get the Label info via a join to the Item, cutting the number of queries in half. In fact, most likely, any time I need an Item I'm going to need it's associated Label as well. Any way I could modify the Item model and tell it to always load it's associated Label? Or am I better off just doing it via contain and leaving well enough alone? Thanks for your quick response! On Jun 7, 1:23 pm, vekija vedran.konto...@gmail.com wrote: It should work with Containable behavior. for example $categories = $this-Category-find('all', array('contain' = array('Item' = array('Label'; should return an array like: Category 1 Item 1 Label 1 Item 2 Label 2 Category 2 Item 3 Label 3 On Jun 7, 10:17 pm, bmcelhany bmcelh...@gmail.com wrote: Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So, Categories and Labels are completely unrelated, but the Item belongs to both of them. Now, in my Category view (and Category controller) I want to display the Cateogry info (obviously) and a list of all of that Category's Items. So far so good. However, what I'd also like is, for each Item that is listed, to display that Item's associated Label. Something like: Category 1 Item 1 (Label for Item 1) Item 2 (Label for Item 2) Category 2 Item 3 (Label for Item 3) I've tried different combinations of recursion (on all three models) and I've tried using the containable behavior but I can't seem to get the Label data to be included. The label data appears fine when I'm working with the Item views and controller, but when I'm up one level higher (in the context of a Category) they aren't attached. Any thoughts on 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
Re: Validate data md5
Right, but not everyone uses secure connection for user registration, and honestly I can't remember a single site which doesn't clear the password field on registration error. On Jun 5, 3:20 am, calvin cal...@rottenrecords.com wrote: I don't get that. I think that presents a false sense of security. It's best practice to use a secure connection whenever you're transmitting passwords. And if you're handling the request over secure http, then it doesn't matter if you send the password back to the user. On Jun 4, 10:08 am, vekija vedran.konto...@gmail.com wrote: When you have an error on the registration form, it is a best practice to clear the password value and force the user to renter that info. So, in the controller... if($this-User-save($this-data)) { // ... whatever you do after user had registered successfully} else { // ... there was an error $this-data['User']['password'] = null; } V On Jun 4, 4:21 pm, Chrriss polet...@wanadoo.fr wrote: Hi, I have a form to add a user and I use an md5 encryption when I save the password in the database. I use $validate to check if the email address is valid. If it's not, the form shows the data again with the error message but the password is not the right one in this case. It's the hashed password. So when I re-enter a valid email address, the password that is saved in the database is not the one I wanted! How can I do ? Thank you in advance! 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
Re: Saving multiple rows of key-value pairs during a single update?
Had a similar issue recently when I was trying to save related data array with associative indexes. Since saveAll() won't work with such indexes I had to convert those to the numeric so I put the code in beforeSave() callback. It didn't work. But when I put the code in the controller just before the saveAll() call everything worked just fine. In my case it was a single line of code so I thought it wouldn't hurt to much if it was there, so I didn't investigated further. On Jun 5, 10:24 pm, mwaterous m...@watero.us wrote: Vekija's method works where mine seems to fail horribly. This has become more of an exploration in Cake than a necessity now, but I'm trying to understand why this particular saveAll() is failing; using the hidden input in combination with the regular input I can effectively save as many rows as I would like to from any given form. However when I try to compensate for the possibility of an associative index appearing in $this-data['MetaUser'] it's failing to insert the rows every time. For example, in my view I have; echo $form-input( 'MetaUser.activation', array( 'type' = 'checkbox', 'label' = 'blah blah blah' ) ); echo $form-input( 'MetaUser.0.meta_key', array( 'type' = 'hidden', 'value' = 'optin' ) ); echo $form-input( 'MetaUser.0.meta_value', array( 'type' = 'checkbox', 'label' = 'I want to receive newsletters and updates via email.' ) ); ...and for clarity it does work fine if I remove the first input, but nevertheless and I'm not sure why, I wanted to write some code to handle this situation transparently. So I wrote a beforeSave() callback in my MetaUser model that looks for such occurrences and fixes them (and then returns true, so that's not the issue). Here is the array at the start of my beforeSave() method; Array ( [MetaUser] = Array ( [activation] = 1 [0] = Array ( [meta_key] = optin [meta_value] = 1 [user_id] = 12 ) ) ) And here it is at the end, right before the return statement; Array ( [MetaUser] = Array ( [0] = Array ( [meta_key] = optin [meta_value] = 1 [user_id] = 12 ) [1] = Array ( [meta_key] = activation [meta_value] = 1 [user_id] = 12 ) ) ) So the array I'm building *looks* like it should work, but after logging the queries and reviewing everything it seems that it doesn't even try to insert the data. It does the first insert, gets the auto_increment value and commits. On Jun 5, 9:32 am, mwaterous m...@watero.us wrote: I have the following in my User model; public $hasMany = array( 'MetaUser' = array( 'className' = 'MetaUser', 'fields' = array( 'meta_key', 'meta_value' ) ) ); ...should I also define a belongsTo relationship from the MetaUser model, or is this necessary when it's being manipulated from the Users controller? On Jun 4, 6:49 pm, calvin cal...@rottenrecords.com wrote: Did you define the relationship between User and MetaUser? i.e. in the User model: $hasMany = array('MetaUser' = array()); Because both, your approach and vekija's, should work. On Jun 4, 9:48 am, mwaterous m...@watero.us wrote: Well my last question here turned out to be between keyboard and chair, so hopefully this isn't quite as silly a question! I am learning Cake and building a custom user authentication system (who isn't?). I am trying to use two separate tables to store data, the User Model table as parent which stores only mission critical data (login, password, email, created, etc), and a MetaUser model table which is built around key value pairs (meta_id, user_id, meta_key, meta_value). Upon registration I have two pieces of meta information I would like to store - the activation code and an optin for receiving communication from site admins. I have built the forms as instructed by the Cake Book in order to use saveAll() in my Register action. The problem is that this results in the following array: Array ( [MetaUser] = Array ( [optin] = 1 [activation_code] = 9c1a26272907d4196a7bf39d [user_id] = 17 ) ) This obviously won't save since there is no optin or activation_code column in the MetaUser table. So I tried creating a beforeSave() under the presumption that if this was a numerical array it might try and add multiple rows on its own; public function beforeSave() { if ( isset( $this-data['MetaUser']['user_id'] ) ) {
Re: Validate data md5
When you have an error on the registration form, it is a best practice to clear the password value and force the user to renter that info. So, in the controller... if($this-User-save($this-data)) { // ... whatever you do after user had registered successfully } else { // ... there was an error $this-data['User']['password'] = null; } V On Jun 4, 4:21 pm, Chrriss polet...@wanadoo.fr wrote: Hi, I have a form to add a user and I use an md5 encryption when I save the password in the database. I use $validate to check if the email address is valid. If it's not, the form shows the data again with the error message but the password is not the right one in this case. It's the hashed password. So when I re-enter a valid email address, the password that is saved in the database is not the one I wanted! How can I do ? Thank you in advance! 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
Re: Saving multiple rows of key-value pairs during a single update?
I think the easier way to accomplish this would be to adapt the view, like this: echo $this-Form-input('MetaUser.0.meta_key', array('type' = 'hidden', 'value' = 'activation_code')); echo $this-Form-input('MetaUser.0.meta_value', array('label' = 'Activation code')); On Jun 4, 6:48 pm, mwaterous m...@watero.us wrote: Well my last question here turned out to be between keyboard and chair, so hopefully this isn't quite as silly a question! I am learning Cake and building a custom user authentication system (who isn't?). I am trying to use two separate tables to store data, the User Model table as parent which stores only mission critical data (login, password, email, created, etc), and a MetaUser model table which is built around key value pairs (meta_id, user_id, meta_key, meta_value). Upon registration I have two pieces of meta information I would like to store - the activation code and an optin for receiving communication from site admins. I have built the forms as instructed by the Cake Book in order to use saveAll() in my Register action. The problem is that this results in the following array: Array ( [MetaUser] = Array ( [optin] = 1 [activation_code] = 9c1a26272907d4196a7bf39d [user_id] = 17 ) ) This obviously won't save since there is no optin or activation_code column in the MetaUser table. So I tried creating a beforeSave() under the presumption that if this was a numerical array it might try and add multiple rows on its own; public function beforeSave() { if ( isset( $this-data['MetaUser']['user_id'] ) ) { $userid = $this-data['MetaUser']['user_id']; $new = array(); $i = 0; foreach ( $this-data['MetaUser'] as $k = $v ) { $new[$i]['user_id'] = $user_id; $new[$i]['meta_key'] = $k; $new[$i]['meta_value'] = $v; $i++; } $this-data['MetaUser'] = $new; } return true; } But apparently it doesn't work that way. I'm going to try it next using distinct save()'s for $this-User and $this-MetaUser but am I missing something else that I should be doing instead? I want to create a MetaUser model where I can save each entry (even if multiple are coming from one form) as separate rows based on the key = value pair setup. 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
Re: Order problem with deep association
Not really sure if it would work but you can try this $this-Shift-find('all', array( 'contain' = array( 'Assignment' = array( )); On Jun 4, 11:29 am, shantamg jason.galu...@gmail.com wrote: yes, that about does it.. but what if i want to order by two fields? something like: Person.category_id asc, Person.name asc On Jun 2, 12:21 am, vekija vedran.konto...@gmail.com wrote: Not sure if I understood the question, but if you want Alix to appear before Shantam you can sort the assignment array with Set::sort Assuming your data array is called $shifts, you could do it like this foreach($shifts as $i = $shift) { $shifts[$i]['Assignment'] = Set::sort($data['Assignment'], '{n}.Person.name', 'asc'); } On Jun 2, 5:52 am, shantamg jason.galu...@gmail.com wrote: Shift hasMany Assignment Assignment belongsTo Person, Shift Person hasMany Assignment So if I do this: $this-Shift-find('all', array( 'contain' = 'Assignment.Person' )); I get something like this: Array ( [0] = Array ( [Shift] = Array ( [id] = 1 etc... [Assignment] = Array ( [0] = Array ( [id] = 1 [person_id] = 1 [shift_id] = 1 etc... [Person] = Array ( [id] = 1 [name] = Shantam etc... ) ) [1] = Array ( [id] = 2 [person_id] = 2 [shift_id] = 1 etc... [Person] = Array ( [id] = 2 [name] = Alix etc... ) ) etc ) ) ) So there's only ever one Person per Assignment. How can I order the Assignments by Person.name? Thanks, Jason 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
Re: Order problem with deep association
Sorry about that, acidently posted before I finished :) $this-Shift-find('all', array( 'contain' = array( 'Assignment' = array( 'Person' = array( 'order' = 'Person.category_id ASC, Person.name ASC' ) ) ) )); On Jun 4, 11:29 am, shantamg jason.galu...@gmail.com wrote: yes, that about does it.. but what if i want to order by two fields? something like: Person.category_id asc, Person.name asc On Jun 2, 12:21 am, vekija vedran.konto...@gmail.com wrote: Not sure if I understood the question, but if you want Alix to appear before Shantam you can sort the assignment array with Set::sort Assuming your data array is called $shifts, you could do it like this foreach($shifts as $i = $shift) { $shifts[$i]['Assignment'] = Set::sort($data['Assignment'], '{n}.Person.name', 'asc'); } On Jun 2, 5:52 am, shantamg jason.galu...@gmail.com wrote: Shift hasMany Assignment Assignment belongsTo Person, Shift Person hasMany Assignment So if I do this: $this-Shift-find('all', array( 'contain' = 'Assignment.Person' )); I get something like this: Array ( [0] = Array ( [Shift] = Array ( [id] = 1 etc... [Assignment] = Array ( [0] = Array ( [id] = 1 [person_id] = 1 [shift_id] = 1 etc... [Person] = Array ( [id] = 1 [name] = Shantam etc... ) ) [1] = Array ( [id] = 2 [person_id] = 2 [shift_id] = 1 etc... [Person] = Array ( [id] = 2 [name] = Alix etc... ) ) etc ) ) ) So there's only ever one Person per Assignment. How can I order the Assignments by Person.name? Thanks, Jason 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
Re: Order problem with deep association
Try this. The code is dirty so you should refactor it :) //sort assignments by person category $data['Assignment'] = Set::sort($data['Assignment'], '{n}.Person.category', 'ASC'); //group assignments by person category //person name is used here as a array key as I'm not sure how to make this with numeric keys :) $data['Assignment'] = Set::combine($data['Assignment'], '{n}.Person.name', '{n}', '{n}.Person.category'); $assignments = array(); foreach($data['Assignment'] as $i=$group) { // revert back tu numeric keys :) $data['Assignment'][$i] = array_values($group); // sort array by person name $data['Assignment'][$i] = Set::sort($data['Assignment'] [$i], '{n}.Person.name', 'ASC'); $assignments = array_merge($assignments, $data['Assignment'][$i]); } $data['Assignment'] = $assignments; Going to bed. Cheers On Jun 4, 11:36 pm, shantamg jason.galu...@gmail.com wrote: yes, but now we're back to the same problem: we are sorting only the one person record inside of each assignment, and we want to sort the assignments. the programatic way you suggested works (i included what I did below), but unlike contain, Set::sort() only takes one sort parameter. if (isset($area['Shift'])) { foreach($area['Shift'] as $shift) { $shift['Assignment'] = Set::sort( $shift['Assignment'], {n}.Person.resident_category_id, asc ); } } On Jun 4, 1:04 pm, vekija vedran.konto...@gmail.com wrote: Sorry about that, acidently posted before I finished :) $this-Shift-find('all', array( 'contain' = array( 'Assignment' = array( 'Person' = array( 'order' = 'Person.category_id ASC, Person.name ASC' ) ) ) )); On Jun 4, 11:29 am, shantamg jason.galu...@gmail.com wrote: yes, that about does it.. but what if i want to order by two fields? something like: Person.category_id asc, Person.name asc On Jun 2, 12:21 am, vekija vedran.konto...@gmail.com wrote: Not sure if I understood the question, but if you want Alix to appear before Shantam you can sort the assignment array with Set::sort Assuming your data array is called $shifts, you could do it like this foreach($shifts as $i = $shift) { $shifts[$i]['Assignment'] = Set::sort($data['Assignment'], '{n}.Person.name', 'asc'); } On Jun 2, 5:52 am, shantamg jason.galu...@gmail.com wrote: Shift hasMany Assignment Assignment belongsTo Person, Shift Person hasMany Assignment So if I do this: $this-Shift-find('all', array( 'contain' = 'Assignment.Person' )); I get something like this: Array ( [0] = Array ( [Shift] = Array ( [id] = 1 etc... [Assignment] = Array ( [0] = Array ( [id] = 1 [person_id] = 1 [shift_id] = 1 etc... [Person] = Array ( [id] = 1 [name] = Shantam etc... ) ) [1] = Array ( [id] = 2 [person_id] = 2 [shift_id] = 1 etc... [Person] = Array ( [id] = 2 [name] = Alix etc... ) ) etc ) ) ) So there's only ever one Person per Assignment. How can I order the Assignments by Person.name? Thanks, Jason 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
Re: Order problem with deep association
Not sure if I understood the question, but if you want Alix to appear before Shantam you can sort the assignment array with Set::sort Assuming your data array is called $shifts, you could do it like this foreach($shifts as $i = $shift) { $shifts[$i]['Assignment'] = Set::sort($data['Assignment'], '{n}.Person.name', 'asc'); } On Jun 2, 5:52 am, shantamg jason.galu...@gmail.com wrote: Shift hasMany Assignment Assignment belongsTo Person, Shift Person hasMany Assignment So if I do this: $this-Shift-find('all', array( 'contain' = 'Assignment.Person' )); I get something like this: Array ( [0] = Array ( [Shift] = Array ( [id] = 1 etc... [Assignment] = Array ( [0] = Array ( [id] = 1 [person_id] = 1 [shift_id] = 1 etc... [Person] = Array ( [id] = 1 [name] = Shantam etc... ) ) [1] = Array ( [id] = 2 [person_id] = 2 [shift_id] = 1 etc... [Person] = Array ( [id] = 2 [name] = Alix etc... ) ) etc ) ) ) So there's only ever one Person per Assignment. How can I order the Assignments by Person.name? Thanks, Jason 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
Re: Photo Uploading,storing in a folder
take a look here http://sabbour.wordpress.com/2008/07/18/enhanced-image-upload-component-for-cakephp-12/ On Nov 16, 5:47 am, arunsab arunsa...@gmail.com wrote: Hi all, i am new in cakephp can anyone show me a sample example of photo uploading in cakephp and same time saving in a folder, -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-...@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=.
Re: install other app under cake
you can put your blog folder next to the app and edit the .htaccess file something like this... IfModule mod_rewrite.c RewriteEngine on RewriteCond%{REMOTE_HOST} !^http://social.cc/blog$ RewriteRule^$ app/webroot/[L] RewriteRule(.*) app/webroot/$1 [L] /IfModule please note that I'm by no means an expert with .htaccess, so this solution might be lacking something important or there might just a better one On Oct 8, 11:25 am, rrd...@gmail.com rrd...@gmail.com wrote: Hari, I have a cake project onhttp://sociall.cc I want to install a wordpress blog tohttp://sociall.cc/blog. Where should I upload wordpress files? It seems if I just upload them to / blog near to /app It will not work. should I put the files to /app/ webroot/blog ? rrd --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Renaming a baked controller
In you viewr add array('action' = 'register') as a second parameter to form create function echo $form-create('ModelName', array('action' = 'register')); On Oct 8, 3:16 pm, toneee toneeeda...@googlemail.com wrote: Hi Guys, Im a little confused, im trying to rename a controller that I have baked. I have created the standard index, add, view and delete controls, but i wanted to rename add to register? I have changed it everywhere I thought I had to, but still when I load the my form called register.ctp (this loads fine) it still trys to send it to the control add? is there something I have missed? Hope someone can help with my stupidity. Kind Regards Toneee --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: regardin options and default
You're missing 'type' parameter... echo $form-input('submited_by', array('type' = 'select', 'options' = $managers, 'selected' = $user_id)); BTW, you can read user's id directly form your view with the session helper... $session-read('UserId'); On Oct 5, 7:00 pm, $$$ sai.cool@gmail.com wrote: add function in the controller:- $userid = $this-Session-read('UserId'); $this-set(compact('userid')); add.ctp echo $form-input('submitted_by',array('options'=$managers,'default'= $userid)); echo $form-input('submitted_by',array('options'= $managers,'default'='$userid')); this doesnt workActually I want to automatically pull up the name of the person from a managers dropdownlist which contains all the managers who logged in this session to use a form --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Email Validation
Add 'allowEmpty' paramter to your email validation rule and set it to true, something like this $validate = array ( 'email' = array('rule' = 'email', 'message' = 'invalid email', 'allowEmpty' = true); ); On Oct 6, 11:03 am, sijo jose jose.s...@gmail.com wrote: Hi folks, I have a email field which is not mandatory. But i would like it to b validated if at all it is entered. Please suggest. -- Sijo Jose Chakramakkil --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How to name the fields when 2 fields in a table refers to same field in another table
in your service model set relation like this $belongsTo = array( 'ServiceProvider' = array( 'className' = 'User', 'foreignKey' = 'served_by' ), 'ServiceUser' = array( 'className' = 'User', 'foreignKey' = 'served_to', ) ); Then yopu can access the user who provides the service with $this- Service-ServiceProvider and the $this-Service-ServiceUser for the one who the service is provided to. Both of this virtual models refer to the User model and users table On Oct 6, 11:22 am, Jiru jiransl...@gmail.com wrote: Hi CakePHP programmers, plz help me.. We have two tables - users and services. services table needs to have two fields (served_by served_to) - both referring to user_id. That case, what should be field names in services table because as per cakephp file naming conventions foreign keys should always be: table_name_in_singular_form_id and in our case it should be user_id. But we can't have two fields with same field name. Any thoughts on how we should name the two fields for services table ? regards, jiru --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Problem with editing in-validated messages
try removing $this-Message-id = $id; and adding parameters to read function at the bottom $this-data = $this-Message-read(null, $id); and placing a hidden input file in your form for message id echo $form-hidden('Message.id'); On Oct 6, 11:22 am, Arak Tai'Roth nielsen.dus...@gmail.com wrote: So, my subject name might be misleading. This is why I'm posting on here because I don't have much of an idea of what to search for in order to find a solution. So here is my issue. I have a controller with an edit function. The page loads fine, it edits fine, and it invalidates fields fine, and it shows which fields had the error fine. However that's where the problem starts that I noticed. If a user types in data that gets invalidated, and then tries to submit it again, it brings up an error that the $id field is missing from the argument (the url), and it is missing. If the user invalidates some data, corrects the issue, and then clicks submit, the data isn't saved but it says it was saved correctly. So my question is, what can I do so that a user can get an invalidated message, but everything will continue working as it is supposed to. Here is my code for the edit function, if you need anything else please just ask. function edit($id) { $this-Message-id = $id; if (!empty($this-data['Message'])) { $mrClean = new Sanitize(); $this-data['Message']['message'] = $mrClean-clean($this-data ['Message']['message'], array('encode' = 0, 'escape' = 0)); $this-data['Message']['modified'] = date('Y-m-d G:i:s'); if ($this-Message-save($this-data['Message'])) { $this-Session-setFlash('The Pastors Message has been edited.'); $this-redirect('/'); $this-exit(); } else { $this-Session-setFlash('The Pastors Message could not be edited.'); } } else { $this-data = $this-Message-read(); } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Problem with editing in-validated messages
From the book: One thing to note here: CakePHP will assume that you are editing a model if the 'id' field is present in the data array. If no 'id' is present (look back at our add view), Cake will assume that you are inserting a new model when save() is called. So, you'd have to add that hidden field to your view in order this to work, but can leave the code in the controller as is On Oct 6, 12:40 pm, Arak Tai'Roth nielsen.dus...@gmail.com wrote: I see what you are saying, I haven't tried this yet. However this seems very hacky to me with the way most things are done in CakePHP. Is this really the way I should go about solving this issue? On Oct 6, 3:57 am, vekija vedran.konto...@gmail.com wrote: try removing $this-Message-id = $id; and adding parameters to read function at the bottom $this-data = $this-Message-read(null, $id); and placing a hidden input file in your form for message id echo $form-hidden('Message.id'); On Oct 6, 11:22 am, Arak Tai'Roth nielsen.dus...@gmail.com wrote: So, my subject name might be misleading. This is why I'm posting on here because I don't have much of an idea of what to search for in order to find a solution. So here is my issue. I have a controller with an edit function. The page loads fine, it edits fine, and it invalidates fields fine, and it shows which fields had the error fine. However that's where the problem starts that I noticed. If a user types in data that gets invalidated, and then tries to submit it again, it brings up an error that the $id field is missing from the argument (the url), and it is missing. If the user invalidates some data, corrects the issue, and then clicks submit, the data isn't saved but it says it was saved correctly. So my question is, what can I do so that a user can get an invalidated message, but everything will continue working as it is supposed to. Here is my code for the edit function, if you need anything else please just ask. function edit($id) { $this-Message-id = $id; if (!empty($this-data['Message'])) { $mrClean = new Sanitize(); $this-data['Message']['message'] = $mrClean-clean($this-data ['Message']['message'], array('encode' = 0, 'escape' = 0)); $this-data['Message']['modified'] = date('Y-m-d G:i:s'); if ($this-Message-save($this-data['Message'])) { $this-Session-setFlash('The Pastors Message has been edited.'); $this-redirect('/'); $this-exit(); } else { $this-Session-setFlash('The Pastors Message could not be edited.'); } } else { $this-data = $this-Message-read(); } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Problem with editing in-validated messages
It's standard practice, whenever you want to edit a record you have to specify it's id in the data array and it's usually done by adding a hidden input in your view On Oct 6, 1:41 pm, Arak Tai'Roth nielsen.dus...@gmail.com wrote: That did indeed work. Thank you very much for your help. However I do have one more question. I never encountered this being added to views in anything that I read about doing data validation. So I am just wondering if I am doing something wrong from the get go that makes it so that I have to add this, or is this just standard practice? On Oct 6, 5:30 am, vekija vedran.konto...@gmail.com wrote: From the book: One thing to note here: CakePHP will assume that you are editing a model if the 'id' field is present in the data array. If no 'id' is present (look back at our add view), Cake will assume that you are inserting a new model when save() is called. So, you'd have to add that hidden field to your view in order this to work, but can leave the code in the controller as is On Oct 6, 12:40 pm, Arak Tai'Roth nielsen.dus...@gmail.com wrote: I see what you are saying, I haven't tried this yet. However this seems very hacky to me with the way most things are done in CakePHP. Is this really the way I should go about solving this issue? On Oct 6, 3:57 am, vekija vedran.konto...@gmail.com wrote: try removing $this-Message-id = $id; and adding parameters to read function at the bottom $this-data = $this-Message-read(null, $id); and placing a hidden input file in your form for message id echo $form-hidden('Message.id'); On Oct 6, 11:22 am, Arak Tai'Roth nielsen.dus...@gmail.com wrote: So, my subject name might be misleading. This is why I'm posting on here because I don't have much of an idea of what to search for in order to find a solution. So here is my issue. I have a controller with an edit function. The page loads fine, it edits fine, and it invalidates fields fine, and it shows which fields had the error fine. However that's where the problem starts that I noticed. If a user types in data that gets invalidated, and then tries to submit it again, it brings up an error that the $id field is missing from the argument (the url), and it is missing. If the user invalidates some data, corrects the issue, and then clicks submit, the data isn't saved but it says it was saved correctly. So my question is, what can I do so that a user can get an invalidated message, but everything will continue working as it is supposed to. Here is my code for the edit function, if you need anything else please just ask. function edit($id) { $this-Message-id = $id; if (!empty($this-data['Message'])) { $mrClean = new Sanitize(); $this-data['Message']['message'] = $mrClean-clean($this-data ['Message']['message'], array('encode' = 0, 'escape' = 0)); $this-data['Message']['modified'] = date('Y-m-d G:i:s'); if ($this-Message-save($this-data['Message'])) { $this-Session-setFlash('The Pastors Message has been edited.'); $this-redirect('/'); $this-exit(); } else { $this-Session-setFlash('The Pastors Message could not be edited.'); } } else { $this-data = $this-Message-read(); } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
sorting records with order by and group by
Hi, I'm having a problem with sorting the recordset with order by and group by statements. Would appreciate any help. There are 2 models, Team and Vote (Team has many Votes) and I want to order teams based on the number of votes they got. Here's the find call: $teams = $this-find('all', array('fields' = 'Vote.team_id', 'order' = 'COUNT('Vote.team_id'), 'group' = 'Vote.team_id')); At the moment there' s only one team in the database with 3 votes. However, the above query returns 2 (duplicate) records but when I place the same query directly in the mysql it works as expected and I get only one. Any ideas? thank you --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Multiple controller for 1 layout
You could use requestAction http://book.cakephp.org/view/434/requestAction but beware of the performance impact it might have On Oct 4, 9:39 pm, f m franck.d...@gmail.com wrote: I'd like to know how to display in a single layout, the result of 2 or more controllers ? Thanks for your help Franck --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Field Naming conventions and hasmany records
You'll have to save the topic first and then fetch it's id. From the cookbook: If neither of the associated model records exists in the system yet (for example, you want to save a new User and their related Profile records at the same time), you'll need to first save the primary, or parent model. http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasMany-belongsTo On Oct 5, 6:27 am, #2Will willjbar...@gmail.com wrote: Hi, I want to add a comment to a new 'Topic' when adding topics. Sort of like a first post of a new forum category. To do this, i was hoping that adding a field like this: echo $form-input('ForumComment.comment'); to my form would create a text area and add the comment in. instead it makes a text input field (which makes me think cake hasn't guessed what im on about, since the comment field is a text type. ) and no comment is saved. Can Cake do this automagicaly, or should i be writing the code to fetch the last topic id, and insert the comment after the topic insert? Thanks for any guidence Will --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: sorting records with order by and group by
yes, that is the case... thanx anyway On Oct 5, 2:55 pm, Bert Van den Brande cyr...@gmail.com wrote: Do you mean that you executed the query from the Cake debug information directly on your mysql-server ? If that is the case I have no idea where the difference in results is coming from ... On Mon, Oct 5, 2009 at 8:32 AM, vekija vedran.konto...@gmail.com wrote: Hi, I'm having a problem with sorting the recordset with order by and group by statements. Would appreciate any help. There are 2 models, Team and Vote (Team has many Votes) and I want to order teams based on the number of votes they got. Here's the find call: $teams = $this-find('all', array('fields' = 'Vote.team_id', 'order' = 'COUNT('Vote.team_id'), 'group' = 'Vote.team_id')); At the moment there' s only one team in the database with 3 votes. However, the above query returns 2 (duplicate) records but when I place the same query directly in the mysql it works as expected and I get only one. Any ideas? thank you --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Admin routing based on a role field
add this to your router file Router::connect('/user/:controller/:action/*', array('prefix' = 'user', 'user' = true)); this will require your actions in the controller to be prefixed as well. In case you want to share actions between the roles but have separate views, you can add a custom parameter as prefix (note the word myprefix instead of prefix in the params array) Router::connect('/user/:controller/:action/*', array('myprefix' = 'user')); Router::connect('/admin/:controller/:action/*', array('myprefix' = 'admin')); Then in the beforeFilter you can check for the prefix with $this- params['myprefix'] and set the view based on that On Oct 5, 4:16 pm, Bidibule bblamp...@tagexpert.be wrote: Hi all! I'm in trouble guys ! :) I want to make differents admin routing based on the user role. Mainly, I have 2 roles : admin and logged user So no problem about using Auth Component and the 'admin' prefix for my views. (admin_index eg) But I think it will be cool to have another prefix for a different role like 'user_index' for the logged user. So I could easily organize my view based on a prefix. But right now I think cake juste allow one admin routing and one prefix so anyone have an idea to do that ? In the beforeFilter method ? Thanks for helping ! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: image path in javascript file
when you call colorpicker function, add options hash as a second parameter {IMAGE_BASE: 'img/'}. Change the path to one where your images are, but if you store them in your app's image folder it should most likely be /img/. Note the leading and trailing slashes, leading one tells the script to start looking in your site's root directory. You don't have to use it but the script will then look for images in the path relative to the current url. The trailing slash is required by the script. On Oct 5, 6:45 pm, emmexx emmeics...@gmail.com wrote: I'm trying to use colorpickerjs in cakephp but I have some trouble with the image files used by this tool. http://code.google.com/p/colorpickerjs/ The javascript file of the tool references all images with the following code: this.options = Object.extend({ IMAGE_BASE : img/ }, options || {}); and then: element.innerHTML='div id=colorpicker-selectorimg src=' + this.options.IMAGE_BASE + 'select.gif width=11 height=11 alt= / /div'; That code translates in the following html inside my cake application: div id=colorpicker-hue-thumb class=selected style=top: 92px; img src=img/hline.png/ /div (just look at the img tag) And of course the image cannot be found... Is there a cakephp way to solve this? I mean, I can't use a htmlHelper, I suppose I should modify the IMAGE_BASE path or put the colorpickerjs files elsewhere (now they are inside webroot/js/ colororpickerjs). I'd prefer non to modify the javascript code. Thank you maxx --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---