Re: Custom Find sending back strange results
Thank you for your reply. It worked to pull the comments but is now pulling all the comments and not just that certain show although it seems to be doing it with the right conditions. Same controller setup as above. Show Model: public function _findComments($state, $query, $results=array()) { if ($state == "before") { $query = $this->__getComments($query['id'], $query['model'], $query); return $query; } else { return $results; } } private function __getComments($id, $model, $query) { $query['contain'] = array( 'Comment'=> array( 'User' => array('fields' => array('id', 'username', 'slug'), 'Image' => array('fields' => array('name')) ), 'conditions' => array( 'Comment.typeID' => 2, 'Comment.model' => 'Show' ), 'limit'=> 5, 'order'=> 'created desc' ) ); return $query; } Here is the SQL dump. The first one is what I need. See the conditions. SELECT `Comment`.`id`, `Comment`.`parent_id`, `Comment`.`user_id`, `Comment`.`typeID`, `Comment`.`model`, `Comment`.`comment`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`typeID` = (2) AND `Comment`.`model` = 'Show' ORDER BY `created` desc LIMIT 5 This one is not what I need. The conditions don't match the find conditions. SELECT `Comment`.`id`, `Comment`.`parent_id`, `Comment`.`user_id`, `Comment`.`typeID`, `Comment`.`model`, `Comment`.`comment`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`typeID` = (3) AND `Comment`.`model` = 'Show' ORDER BY `created` desc LIMIT 5 Thank you again. Brad On Apr 30, 11:32 am, stas kim wrote: > i can tell where the errors come from > in you __getComments you overwrite $query with actual dataset returned > by Comment->find which is wrong > because the $query var is passed to Model->find and it gets confused > with your data > > what you need to do is build a proper contain > $query['contain'] = array( > 'Comment'=> array( > 'User'=>array(), > 'limit'=> > 'order'=> 'field name desc' > ) > ) > return $query > > That way you will get your Shows paginated containing comments->userinfo > > > > On Thu, Apr 28, 2011 at 9:07 PM,bradmaxs wrote: > > All I want to do is have one find for my comments in each associated > > model. I would love to do this in the Comment model and only have to > > do it once but that wasn't working out. > > > SHOW CONTROLLER > > > $this->paginate = array('comments', 'id' => $show['Show']['id'], > > 'model' => 'Show'); > > $comments = $this->paginate(); > > $this->set(compact('show', 'comments')); > > > SHOW MODEL > > > public $_findMethods = array('comments' => true); > > > public function _findComments($state, $query, $results=array()) { > > if ($state == "before") { > > $query = $this->__getComments($query['id'], $query['model'], > > $query); > > return $query; > > } else { > > return $results; > > } > > } > > > private function __getComments($id, $model, $query) { > > $query = ClassRegistry::init('Comment')->find('all', array( > > 'contain' => array( > > 'User' => array( > > 'fields' => array('id', 'username', > > 'slug'), > > 'Image' => array( > > 'fields' => array('name') > > ) > > ) > > ), > > 'conditions' => array( > > 'Comme
Custom Find sending back strange results
All I want to do is have one find for my comments in each associated model. I would love to do this in the Comment model and only have to do it once but that wasn't working out. SHOW CONTROLLER $this->paginate = array('comments', 'id' => $show['Show']['id'], 'model' => 'Show'); $comments = $this->paginate(); $this->set(compact('show', 'comments')); SHOW MODEL public $_findMethods = array('comments' => true); public function _findComments($state, $query, $results=array()) { if ($state == "before") { $query = $this->__getComments($query['id'], $query['model'], $query); return $query; } else { return $results; } } private function __getComments($id, $model, $query) { $query = ClassRegistry::init('Comment')->find('all', array( 'contain' => array( 'User' => array( 'fields' => array('id', 'username', 'slug'), 'Image' => array( 'fields' => array('name') ) ) ), 'conditions' => array( 'Comment.typeID' => $id, 'Comment.model' => $model ), 'limit' => 5, 'order' => array('Comment.created' => 'desc') )); return $query; } RESULTS This is the one I want: SELECT `Comment`.`id`, `Comment`.`parent_id`, `Comment`.`user_id`, `Comment`.`typeID`, `Comment`.`model`, `Comment`.`comment`, `Comment`.`created`, `Comment`.`modified`, `User`.`id`, `User`.`username`, `User`.`slug` FROM `comments` AS `Comment` LEFT JOIN `users` AS `User` ON (`Comment`.`user_id` = `User`.`id`) WHERE `Comment`.`typeID` = 2 AND `Comment`.`model` = 'Show' ORDER BY `Comment`.`created` desc LIMIT 5 This is also on the sql log and it seems to be the one the view is using: SELECT `Comment`.`id`, `Comment`.`parent_id`, `Comment`.`user_id`, `Comment`.`typeID`, `Comment`.`model`, `Comment`.`comment`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`typeID` IN (2, 3) ORDER BY `Comment`.`created` DESC I don't even understand where it is coming from because I didn't define it. And I get these errors: Notice (8): Undefined index: page [CORE/cake/libs/model/model.php, line 2094] Notice (8): Undefined index: order [CORE/cake/libs/model/model.php, line 2100] Notice (8): Undefined index: order [CORE/cake/libs/model/model.php, line 2103] Notice (8): Undefined index: callbacks [CORE/cake/libs/model/ model.php, line 2105] Notice (8): Undefined index: callbacks [CORE/cake/libs/model/ model.php, line 2130] -- 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
David Persson Media Plugin
More than one of my apps are doing this so I am very confused. I am using Show hasMany Attachment. I try and create a new record and it uploads and resizes the image and saves the record to my Attachment model without a foreign_key but with the correct model (Show). However, it does NOT save the main record in my Show model. The flash says the record has been saved but it hasn't. If I EDIT a preexisting record, the image is uploaded, resized and saved to the Attachment db with the foreign_key. Any help would be greatly appreciated. I would really like to be able to use this plugin as it looks amazing but can't figure this one hurdle out. Thank you. show.php var $actsAs = array( 'Sluggable' => array('overwrite' => 'true'), 'Tags.Taggable', 'Media.Transfer', 'Media.Generator', 'Media.Coupler' ); var $hasMany = array( 'Attachment' => array( 'className' => 'Media.Attachment', 'foreignKey' => 'foreign_key', 'dependent' => true, 'conditions' => array('Attachment.model' => 'Show') ), ); shows_controller.php function admin_add() { if (!empty($this->data)) { $this->Show->create(); if ($this->Show->saveAll($this->data, array('validate' => 'first'))) { $this->Session->setFlash(__('The show has been saved', true)); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The show could not be saved. Please, try again.', true)); } } $users = $this->Show->User->find('list', array( 'conditions' => array('User.group_id' => array('1', '3')), 'fields' => array('User.username'), 'order' => array('User.username' => 'asc') ) ); $this->set(compact('users')); } function admin_edit($id = null) { if (!$id && empty($this->data)) { $this->Session->setFlash(__('Invalid show', true)); $this->redirect(array('action' => 'index')); } if (!empty($this->data)) { if ($this->Show->saveAll($this->data, array('validate' => 'first'))) { $this->Session->setFlash(__('The show has been saved', true)); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The show could not be saved. Please, try again.', true)); } } if (empty($this->data)) { $this->data = $this->Show->read(null, $id); } $users = $this->Show->User->find('list', array( 'conditions' => array('User.group_id' => array('1', '3')), 'fields' => array('User.username'), 'order' => array('User.username' => 'asc') ) ); $this->set(compact('users')); } admin_add.ctp Form->create('Show', array('enctype' => 'multipart/ form-data'));?> Form->input('user_id', array('empty' => true)); echo $this->Form->input('title'); echo $this->Form->input('description'); echo $this->element('attachments', array('plugin' => 'media')); echo $this->Form->input('tags', array('type' => 'text')); ?> Form->end(__('Submit', true));?> -- 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: PayPal Payments Pro Component Help
Thanks @euromark, I tried your solution today and Viola - it worked. Now just some configuration of my cart and I am ready to go. Thank you for pointing me there! Brad On Sep 19, 8:02 am, euromark wrote: > its quite old > maybe something changed in the api? > > this seems to be more up to > date:http://bakery.cakephp.org/articles/view/paypal-payments-component-usi... > > i got it to work, anyway > > On 19 Sep., 06:45, bradmaxs wrote: > > > > > Hi Cakers, > > > I am trying to integrate the PayPal Component by Mariano Iglesias and > > I am having trouble understanding how to implement the form and then > > the controller action to call the component. > > > I have set up a form for the checkout and then I am calling a checkout > > function in my carts controller. > > > From there I am then calling the PayPal component like this > > > function checkout($id = null) { > > if (!empty($this->data)) { > > $this->Paypal->directPayment(); > > debug($this->data); > > > } > > } > > > but nothing is happening except the a redirect back to the checkout > > view with the form reloaded. > > > Am I calling the component the wrong way? > > > I have searched for any form and controller examples with no avail. > > Any help is appreciated. > > > Thank you, > > > Brad 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
PayPal Payments Pro Component Help
Hi Cakers, I am trying to integrate the PayPal Component by Mariano Iglesias and I am having trouble understanding how to implement the form and then the controller action to call the component. I have set up a form for the checkout and then I am calling a checkout function in my carts controller. >From there I am then calling the PayPal component like this function checkout($id = null) { if (!empty($this->data)) { $this->Paypal->directPayment(); debug($this->data); } } but nothing is happening except the a redirect back to the checkout view with the form reloaded. Am I calling the component the wrong way? I have searched for any form and controller examples with no avail. Any help is appreciated. Thank you, Brad 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
Deleting session array
Hey All, I am trying to make a simple shopping cart system and am having trouble deleting a product from the cart. I have a simple delete link: Html->link(__('remove', true), array('controller' => 'carts', 'action' => 'delete', $item['Cart']['id']), null, sprintf(__('Are you sure you want to remove %s?', true), $item['Cart'] ['name'])); ?> Two sample arrays: Array ( [0] => Array ( [_Token] => Array ( [key] => e031095578e465bb5c3b7c11318db719fc87a210 [fields] => 8a8d3d32d202af510d5ba014c4904cd1540502a2%3An%3A3%3A%7Bv%3A0%3Bf%3A7%3A %22Pneg.vq%22%3Bv%3A1%3Bf%3A9%3A%22Pneg.anzr%22%3Bv%3A2%3Bf%3A10%3A %22Pneg.cevpr%22%3B%7D ) [Cart] => Array ( [id] => 10 [name] => Credits [price] => 15.00 [qty] => 10 ) ) [1] => Array ( [_Token] => Array ( [key] => e031095578e465bb5c3b7c11318db719fc87a210 [fields] => f77394c7e062f7b991d47ddba244bd20de4ffa87%3An%3A3%3A%7Bv%3A0%3Bf%3A7%3A %22Pneg.vq%22%3Bv%3A1%3Bf%3A9%3A%22Pneg.anzr%22%3Bv%3A2%3Bf%3A10%3A %22Pneg.cevpr%22%3B%7D ) [Cart] => Array ( [id] => 20 [name] => Audio [price] => 25.00 [qty] => 20 ) ) ) Here is my delete function in the controller. function delete($id = null) { if ($this->Session->delete('sCart.0.Cart.id')) { $this->Session->setFlash(sprintf(__('%s removed', true), 'Item')); $this->redirect(array('controller' => 'credits', 'action'=>'addcredits', 8)); } $this->Session->setFlash(sprintf(__('%s was not removed', true), 'Item')); $this->redirect(array('controller' => 'credits', 'action'=>'addcredits', 8)); } It is deleting the id field from the array but not the array itself. I am also worried that it may not delete the token of that array either. Is there a way to add some kind of id to each main array so the delete takes care of the token and Cart arrays inside the main array? Thank you for your help. Brad 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: Easy cake pagination!
Does your Count model have a count field and if so, how does that relate to Place? I am a little confused about what you are trying to do. Does your Count model have a place_id for the relationship reference? One thing you could try is in the hasMany array in the Place model you could always declare the order there. var $hasMany = array( 'Count' => array( 'className' => 'Count', 'foreignKey' => 'place_id', 'order' => 'Count.count ASC', ) ); http://book.cakephp.org/view/1043/hasMany On Aug 19, 4:42 am, Okalany Daniel wrote: > The SQL Query generated doesn't have a join: > > *Warning* (512) : *SQL Error:* 1054: Unknown > column 'Count.count' in 'order clause' > [*CORE\cake\libs\model\datasources\dbo_source.php*, line *673*] > Code | Context > > $out = null; if ($error) { > trigger_error('' . __('SQL > Error:', true) . " {$this->error}", E_USER_WARNING); > > $sql = "SELECT `Place`.`id`, `Place`.`name`, `Place`.`guy_count` FROM > `places` AS `Place` WHERE 1 = 1 ORDER BY `Count`.`count` ASC " > $error = "1054: Unknown column 'Count.count' in 'order clause'" > $out = null > > DboSource::showQuery() - > CORE\cake\libs\model\datasources\dbo_source.php, line 673 > DboSource::execute() - CORE\cake\libs\model\datasources\dbo_source.php, line > 263 > DboSource::fetchAll() - > CORE\cake\libs\model\datasources\dbo_source.php, line 407 > DboSource::read() - CORE\cake\libs\model\datasources\dbo_source.php, line 812 > Model::find() - CORE\cake\libs\model\model.php, line 2090 > PlacesController::index() - APP\controllers\places_controller.php, line 16 > Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204 > Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171 > [main] - APP\webroot\index.php, line 83 > > *Query:* SELECT `Place`.`id`, `Place`.`name`, `Place`.`guy_count` FROM > `places` AS `Place` WHERE 1 = 1 ORDER BY `Count`.`count` ASC > > > > > > On Wed, Aug 18, 2010 at 8:59 PM, bradmaxs wrote: > > What fields do you have in the Count table? When I get this error it > > is because the join was incorrect - usually. Also - when the errors > > occur, usually there is a code and a context link that will show you > > more of the dump when clicked on and what the conflicting code is. It > > should have also printed out the sql query at the top and you can see > > the exact query and troubleshoot from there. > > > On Aug 17, 6:07 am, Okalany Daniel wrote: > > > the model Place hasMany Count, and Count belongs to place. > > > So using the Containable behaviour, i can specify conditions for child > > > fields like: > > > > $this->Place->Behaviors->attach('Containable'); > > > $this->paginate['Place'] = array( > > > 'contain' => array('Count'=>array( > > > 'conditions'=>array('Count.date'=>date('Y-m-d')) > > > )), > > > //'order' => 'Count.count DESC' > > > ); > > > $places = $this->paginate('Place'); > > > > But i'd like to order the parent Model by a field in a child model. When > > i > > > uncomment the line that starts 'order', i get the error: > > > SQL Error: 1054: Unknown column 'Count.count' in 'order clause' > > > > Thanks in advance. > > > > On Tue, Aug 17, 2010 at 10:28 AM, AD7six wrote: > > > > > On Aug 16, 5:25 pm, Okalany Daniel wrote: > > > > > Hi, Andy Dawson, > > > > > i'm having a similar problem, > > > > > How similar is your sql error or code ? I find it hard to compare to > > > > things I can't see :). > > > > > > but i don't understand your fix. > > > > > I didn't get as far as to propose a fix. However I'll give you this > > > > hint: the book almost certainly has a relevant example and hasMany/ > > > > hasAndBelongsToMany don't generate joins in the main query - hasOnes > > > > do. > > > > > AD > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp > > others > > > > with their CakePHP related questions. > > > > > You received this message because you are subscribed to the Google > > Groups > > >
Re: Easy cake pagination!
What fields do you have in the Count table? When I get this error it is because the join was incorrect - usually. Also - when the errors occur, usually there is a code and a context link that will show you more of the dump when clicked on and what the conflicting code is. It should have also printed out the sql query at the top and you can see the exact query and troubleshoot from there. On Aug 17, 6:07 am, Okalany Daniel wrote: > the model Place hasMany Count, and Count belongs to place. > So using the Containable behaviour, i can specify conditions for child > fields like: > > $this->Place->Behaviors->attach('Containable'); > $this->paginate['Place'] = array( > 'contain' => array('Count'=>array( > 'conditions'=>array('Count.date'=>date('Y-m-d')) > )), > //'order' => 'Count.count DESC' > ); > $places = $this->paginate('Place'); > > But i'd like to order the parent Model by a field in a child model. When i > uncomment the line that starts 'order', i get the error: > SQL Error: 1054: Unknown column 'Count.count' in 'order clause' > > Thanks in advance. > > > > > > On Tue, Aug 17, 2010 at 10:28 AM, AD7six wrote: > > > On Aug 16, 5:25 pm, Okalany Daniel wrote: > > > Hi, Andy Dawson, > > > i'm having a similar problem, > > > How similar is your sql error or code ? I find it hard to compare to > > things I can't see :). > > > > but i don't understand your fix. > > > I didn't get as far as to propose a fix. However I'll give you this > > hint: the book almost certainly has a relevant example and hasMany/ > > hasAndBelongsToMany don't generate joins in the main query - hasOnes > > do. > > > AD > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com > om>For more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en > > -- > OKALANY DANIEL, > P.O BOX 26150, > Kampala., > Uganda.http://okasoft.net > -- > When confronted by our worst nightmares, the choices are few; Fight or > flight. We hope to find the strength to stand against our fears but > sometimes, despite ourselves, we run. What if the nightmare gives chase? > Where can we hide then? 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: Easy cake pagination!
What is the relationship of the category and picture table? It seems that the pictures should possibly have a has one category and games has many pictures. When you look at the picture array, there is no category reference there. I would think there would need to be a category_id for it to be possible. Haven't had coffee yet so go easy. On Aug 16, 7:27 am, Abraham Boray wrote: > Guys I'm lost, in the middle of a project I have to separate between > two pictures form > 1- Pictures 4 the iPhone > 2- Pictures 4 the Web > > I get this array from the controller by callin : > $this->Picture->recursive = 0; > $this->set('pictures', $this->paginate()); > > the array is a set of pictures and the GAME (to which they belong) > And every game have a CATEGORY > > Array > ( > [0] => Array > ( > [Picture] => Array > ( > [id] => 1 > [name] => Image_15.png > [type] => image/png > [size] => 328004 > [filesize] => 320 KB > [ext] => png > [group] => image > [path] => /files/iPhone/Image_15.png > [created] => 2010-08-02 16:19:33 > [modified] => 2010-08-02 16:19:33 > [type_id] => 30 > ) > ) > > [Game] => Array > ( > [0] => Array > ( > [id] => 9 > [game_name] => Game2 > [GamesPicture] => Array > ( > [id] => 43 > [game_id] => 9 > [picture_id] => 24 > ) > > [Category] => Array > ( > [id] => 3 > [name] => web > ) > ) > ) > ) > > So wot I want is to paginate this including just the web CATEGORY > PICTURES(Filtring) > WHERE CATEGORY.nam='web' > > I tried this but it'snot working : > /// > > $this->set('pictures', $this->paginate('conditions' => > array('Category.name' => 'web'))); > > this is the database structure so to get a clearer IDEA. > /// > > Field TABLE PICTURE > id > name > type > size > int(11) > filesize > group > type_id int(11) > > Field TABLE GAME > id > game_name > start_date > end_date > category_id > modified > > Field TABLE Games_pictures > id > game_id > picture_id > > Thank u guys 4 ur future help, I'm stuck and got really to get this > done as soon as I can Fix it > Thank u in advance > {A|B} 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: How to use SEO urls in CakePHP without the ID?
Hi Cricket, Thanks for the reply about the behavior being compatible with 1.3. It sure is and what a great behavior it is. I got it up and running in under 5 minutes with NO hassle. Something that happens almost never for me:) Brad On Jul 14, 9:12 am, cricket wrote: > On Wed, Jul 14, 2010 at 5:42 AM, alopes wrote: > > Hello, > > > How i can route my URLs without showing the ID in the URL. For example > > i have: > > >www.mywebsite.com/id-article-title.htmland i want only > >www.mywebsite.com/article-title.html > > Add a column to your table to hold the "slug", which will be the title > string after it's been set to lowercase and all spaces converted to > hyphens (or underscores). Then add SluggableBehavior to your model. > See here: > > http://bakery.cakephp.org/articles/view/sluggable-behavior > > Set up a route: > > Router::connect( > '/articles/:slug', > array( > 'controller' => 'articles', > 'action' => 'view' > ), > array( > 'slug' => '[-a-z0-9]+', > 'pass' => array('slug') > ) > ); > > Note that the URL begins with '/articles/'. It can be whatever string > you want but if you leave it out (so that the URL begins with the > slug), you'll have to create a route for every other controller action > in your app or every request will be sent to ArticlesController. > > public function view($slug = null) > { > if (empty($slug)) > { > // redirect ... > } > > $data = $this->Article->find( > 'first', > array( > 'conditions' => array('Article.slug' => $slug) > ) > ); > > ... > > > > } 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: Ajax Pagination cakePHP 1.3 and jQuery
Thank you for your help. I added the file to the helpers and changed the code and nothing changed:( Before I had the pagination outside of the element and now I have moved it inside the element and it seems to have made a change. Before it worked but only if I clicked on the numbers or like I explained if I clicked on next but only the first time. Now it seems to work every other link. So when I go to the page and click on the next it goes to the next page without a refresh. If I click on next to go to the third page it does do that within the links but it refreshes the page. So I am getting every other page by ajax. Here is the javascript at the bottom. It still says bind even though I added the helper with the changed code. Is this correct looking. //<![CDATA[ $(document).ready(function () {$("#link-1109729578").bind("click", function (event) {$.ajax({dataType:"html", success:function (data, textStatus) {$("#comment").html(data);}, url:"\/thegarage\/view\/22\/ page:2"}); return false;}); $("#link-922906323").bind("click", function (event) {$.ajax({dataType:"html", success:function (data, textStatus) {$ ("#comment").html(data);}, url:"\/thegarage\/view\/22\/page:1"}); return false;}); $("#link-1486848737").bind("click", function (event) {$.ajax({dataType:"html", success:function (data, textStatus) {$ ("#comment").html(data);}, url:"\/thegarage\/view\/22\/page:2"}); return false;});}); //]]> Thank you so much for helping. Brad On Aug 3, 11:42 pm, "ecommy.com" wrote: > This is a common problem - and is because jquery doesn't work similar > with prototype when it comes to executing ajax code inside a page that > was requested by ajax > > jquery has live event feature to acomplish that copy > cake/libs/view/helpers/jquery_engine.php to > app/views/helpers/jquery_engine.php > > now open jquery_engine.php and on line 181 change the code from: > > return sprintf('%s.bind("%s", %s);', $this->selection, $type, > $callback); > > to > > return sprintf('%s.live("%s", %s);', $this->selection, $type, > $callback); //ecommy.com modified code > > On Aug 4, 12:06 am, bradmaxs wrote: > > > > > I have set up pagination following the Mark Story article and it seems > > to work fine EXCEPT my next, previous and number links are not > > updating. > > > If I click on next after the first page load, it goes to the next > > comment (cool), however the next link does not update to the third > > page and just stops working. I can use the number links to each page > > and they work fine but they don't update either so I can never get > > back to page 1 without a refresh and you never know where you are. > > > Here is lies the rub. I am using one model for the main content of > > the page and contain for the comments. Here is my controller code. > > > // VIEW > > function view($id = null) { > > if (!$id) { > > $this->Session->setFlash(sprintf(__('Invalid %s', > > true), 'cshow')); > > $this->redirect(array('action' => 'index')); > > } > > $this->set('cshow', $this->Cshow->read(null, $id)); > > $this->paginate = array( > > 'contain' => array( > > 'User' => array( > > 'UserPreference.image' > > ), > > ), > > 'fields' => array( > > 'CshowComment.id', 'CshowComment.user_id', > > 'CshowComment.comment', > > 'CshowComment.created', 'User.id', 'User.username' > > ), > > 'conditions' => array( > > 'CshowComment.cshow_id' => $id > > ), > > 'recursive' => 0, > > 'limit' => 1, > > 'order' => array( > > 'CshowComment.created' => 'desc' > > ) > > ); > > $this->set('cshowComment', $this->paginate('CshowComment')); > >
Ajax Pagination cakePHP 1.3 and jQuery
I have set up pagination following the Mark Story article and it seems to work fine EXCEPT my next, previous and number links are not updating. If I click on next after the first page load, it goes to the next comment (cool), however the next link does not update to the third page and just stops working. I can use the number links to each page and they work fine but they don't update either so I can never get back to page 1 without a refresh and you never know where you are. Here is lies the rub. I am using one model for the main content of the page and contain for the comments. Here is my controller code. // VIEW function view($id = null) { if (!$id) { $this->Session->setFlash(sprintf(__('Invalid %s', true), 'cshow')); $this->redirect(array('action' => 'index')); } $this->set('cshow', $this->Cshow->read(null, $id)); $this->paginate = array( 'contain' => array( 'User' => array( 'UserPreference.image' ), ), 'fields' => array( 'CshowComment.id', 'CshowComment.user_id', 'CshowComment.comment', 'CshowComment.created', 'User.id', 'User.username' ), 'conditions' => array( 'CshowComment.cshow_id' => $id ), 'recursive' => 0, 'limit' => 1, 'order' => array( 'CshowComment.created' => 'desc' ) ); $this->set('cshowComment', $this->paginate('CshowComment')); if ($this->RequestHandler->isAjax()) { $this->render('/elements/comments'); return; } $this->set('title_for_layout', 'eGarage.tv - View The Garage Show'); } In the view: element('comments'); ?> options(array('update' => '#comment')); ?> Paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> | Paginator- >numbers();?> | Paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> Paginator- >counter(array('format' => __('%page% of %pages%, %count% Comments', true)));?> and I have included the Js helper and the RequestHandler component in my appController as well as Js->writeBuffer(); ?> in my default layout right before the tag. Not sure if this could be the problem but I am serving jQuery from a CDN and not from the webroot/js folder. I am using an element because if I don't the page duplicates the content that I am trying to update instead of loading via AJAX. This may be the problem but I am stuck. I can post other code if this doesn't tell the whole story. Thanks 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: HABTM Containable find('all') question
Hey Paul, Just wanted to update you. I could never get it working. Tried the examples above and couldn't come up with anything. Finally got back to it today and just added an if clause to the view to filter out result that had that parameter. Not sure if it is the best but it is working well. Thanks for all of your help. I did learn a lot along the way so it wasn't in vein I assure you. Brad On May 31, 3:33 am, WebbedIT wrote: > Your double join on the same table is fine, I just didn't notice it. > > Can you try this instead? > > SELECT DISTINCT User.id, User.username FROM users AS User > LEFT JOIN friends AS Friend ON (User.id = Friend.user_id AND > Friend.approved IN(0,1)) > LEFT JOIN friends AS Admirer ON (User.id = Admirer.friend_id AND > Admirer.approved IN(0,1)) > > Does this give the desired results where the Friend count is the > amount of records where friends.user_id matches the current user and > the Admirer count is the number of friends where friends.friend_id > matches the current users. > > If this works and pulls the data you are sure it should pull then we > simply need to force some joins in Cake using: > > http://book.cakephp.org/view/86/Creating-and-Destroying-Associations-... > > or > > http://book.cakephp.org/view/872/Joining-tables > > HTH > > Paul 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: Nick Baker's FileUpload
Hi Nick, Sorry for the lapse but was busy with other projects. The issue is that the file is going to a different folder that has nothing to do with this model or controller or form?? The record is being saved to the DB in the correct table but is getting uploaded to the a directory that is specified in another models controller and there are no relationships between the two. What seems strange is that this is the only model it is happening for and I have 3 other models where it works correctly. You said different upload directories are not supported yet but wouldn't that not matter since I am using it as a stand alone component on each different model? Meaning, it is declared in the Model in the actsAs var. "However, until then, a patch to make it work the way you expect would be to unbind the behavior and then rebind it before the final save, forcing correct configuration to be used at that save." I am sorry to be a newbie but could you give me a small example if it is small or point me in the direction of how to do that? Also - I am trying to upload an mp3 file on another model and nothing is happening. The browser acts like it is doing something and then comes back saying that the file has been saved but the record is not there and the file is not uploaded. I am using the same ADD function that works for all the other uploads and in the model I have this. I have printed out the data and it seems that the type and size are not being read?? The funny thing is is I have required set to false and the record is still not saving even if the file field is left blank. Here is what I have for the actsAs var $actsAs = array( 'FileUpload.FileUpload' => array( 'uploadDir' => 'files/audio', 'fields' => array('name' => 'file_url', 'type' => 'file_type', 'size' => 'file_size'), 'allowedTypes' => array('mp3' => array('audio/mp3', 'audio/ mpeg', 'audio/x-mpeg', 'audio/mp3', 'audio/x-mp3', 'audio/mpeg3', 'audio/x-mpeg3', 'audio/mpg', 'audio/x-mpg', 'audio/x-mpegaudio')), 'required' => false, //default is false, if true a validation error would occur if a file wsan't uploaded. 'maxFileSize' => '10485760', //bytes OR false to turn off maxFileSize (default false) 'unique' => true //filenames will overwrite existing files of the same name. (default true) //'fileNameFunction' => 'sha1' //execute the Sha1 function on a filename before saving it (default false) ) ); Array ( [_Token] => Array ( [key] => d3ac1dcc08333b2c6ce2243d0f95abe72def82d8 [fields] => 6cbbe5f975cba1b5eb40acf446944f4089d8f111%3An %3A1%3A%7Bv%3A0%3Bf%3A13%3A%22Nhqvb.hfre_vq%22%3B%7D ) [Audio] => Array ( [user_id] => 1 [title] => new [description] => new [price] => .99 [file] => Array ( [name] => norib.mp3 [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) [AudioCategory] => Array ( [AudioCategory] => Array ( [0] => 3 [1] => 4 ) ) ) Nick, thanks again for all of your help. I really do appreciate it. Brad On Jul 5, 9:44 pm, nurvzy wrote: > Hi, > > Well that looks A-OK to me. Error code 0 is a good thing. So the > issue it is not being saved to the file system or that it's not in the > directory you expected it to be? Different upload directories is not > officially supported yet but it is slated to be in the next release. > The tricky part being how the helper decides where a file is based on > which model configuration it decides to use. What's probably > happening is depending on how your models are being constructed, and > instantiated in which order the configuration for each model is > overwriting the previous configuration. In the next release each > configuration will be cached on a model key as to not conflict with > one another. However, until then, a patch to make it work the way you > expect would be to unbind the behavior and then rebind it before the > final save, forcing correct configuration to be used at that save. > > This solution is not ideal, I expect to have the next release ready > this month. > > Hope that helps, > Nick > > On Jul 5, 7:55 pm, br
Re: Nick Baker's FileUpload
Here it is! Array ( [_Token] => Array ( [key] => 41294a9d9841267a9d32777ebd041179ba6a0a89 [fields] => e26baca1e6f629a524452b4f7a8e3fa7f8f45a9e%3An %3A0%3A%7B%7D ) [Egaragead] => Array ( [website] => http://www.puddly.com [description] => Description [position] => 5 [file] => Array ( [name] => outtamustard.jpg [type] => image/jpeg [tmp_name] => /tmp/phpubfDP3 [error] => 0 [size] => 48661 ) ) ) On Jul 5, 6:44 pm, nurvzy wrote: > Ok. Thanks for sharing that, I don't see any glaringly obvious > culprits in your configuration. How are you passing data into your > Egaragead model? Would you mind running a debug($this->data) before > you pass it to Egaragead->save() and post it? > > Thanks, > Nick > > On Jul 5, 7:18 pm, bradmaxs wrote: > > > > > Hey Nick, > > > Thank you. It is great right out of the box. > > > I am using actsAs for all of them actually. > > > Here are the three that are goofing with me. > > > Upon further exploration as noted above I removed the cshow model and > > it started going into the artist_preference model?? > > > Then I removed that one and it didn't upload at all. I put the cshow > > back up and voila, right back into the folder specified for that > > model. So weird huh? > > > Thanks again. > > > Here is the model code. > > > cshow: > > > class Cshow extends AppModel { > > var $name = 'Cshow'; > > var $actsAs = array( > > 'FileUpload.FileUpload' => array( > > 'uploadDir' => 'files/img_thegarage', > > 'fields' => array('name' => 'image', 'type' => 'image_type', > > 'size' => 'image_size'), > > //'allowedTypes' => array('pdf' => array('application/ > > pdf')), > > 'required' => false, //default is false, if true a > > validation error would occur if a file wsan't uploaded. > > 'maxFileSize' => '2097152', //bytes OR false to turn off > > maxFileSize (default false) > > 'unique' => true //filenames will overwrite existing files > > of the same name. (default true) > > //'fileNameFunction' => 'sha1' //execute the Sha1 function > > on a filename before saving it (default false) > > ) > > ); > > > I have some validation and it hasMany cshow_comment. > > > artist_preference > > > class ArtistPreference extends AppModel { > > var $name = 'ArtistPreference'; > > var $actsAs = array( > > 'FileUpload.FileUpload' => array( > > 'uploadDir' => 'files/img_artisticon', > > 'fields' => array('name' => 'image', 'type' => 'image_type', > > 'size' => 'image_size'), > > //'allowedTypes' => array('pdf' => array('application/ > > pdf')), > > 'required' => false, //default is false, if true a > > validation error would occur if a file wasn't uploaded. > > 'maxFileSize' => '2097152', //bytes OR false to turn off > > maxFileSize (default false) > > 'unique' => true //filenames will overwrite existing files > > of the same name. (default true) > > //'fileNameFunction' => 'sha1' //execute the Sha1 function > > on a filename before saving it (default false) > > ) > > ); > > > validation again and it belongsTo user and band > > > AND THE CULPRIT: > > > egaragead > > > class Egaragead extends AppModel { > > var $name = 'Egaragead'; > > var $actsAs = array( > > 'FileUpload.FileUpload' => array( > > 'uploadDir' => 'files/img_egarageads', > > 'fields' => array('name' => 'image', 'type' => 'image_type', > > 'size' => 'image_siz
Re: Nick Baker's FileUpload
Hey Nick, Thank you. It is great right out of the box. I am using actsAs for all of them actually. Here are the three that are goofing with me. Upon further exploration as noted above I removed the cshow model and it started going into the artist_preference model?? Then I removed that one and it didn't upload at all. I put the cshow back up and voila, right back into the folder specified for that model. So weird huh? Thanks again. Here is the model code. cshow: class Cshow extends AppModel { var $name = 'Cshow'; var $actsAs = array( 'FileUpload.FileUpload' => array( 'uploadDir' => 'files/img_thegarage', 'fields' => array('name' => 'image', 'type' => 'image_type', 'size' => 'image_size'), //'allowedTypes' => array('pdf' => array('application/ pdf')), 'required' => false, //default is false, if true a validation error would occur if a file wsan't uploaded. 'maxFileSize' => '2097152', //bytes OR false to turn off maxFileSize (default false) 'unique' => true //filenames will overwrite existing files of the same name. (default true) //'fileNameFunction' => 'sha1' //execute the Sha1 function on a filename before saving it (default false) ) ); I have some validation and it hasMany cshow_comment. artist_preference class ArtistPreference extends AppModel { var $name = 'ArtistPreference'; var $actsAs = array( 'FileUpload.FileUpload' => array( 'uploadDir' => 'files/img_artisticon', 'fields' => array('name' => 'image', 'type' => 'image_type', 'size' => 'image_size'), //'allowedTypes' => array('pdf' => array('application/ pdf')), 'required' => false, //default is false, if true a validation error would occur if a file wasn't uploaded. 'maxFileSize' => '2097152', //bytes OR false to turn off maxFileSize (default false) 'unique' => true //filenames will overwrite existing files of the same name. (default true) //'fileNameFunction' => 'sha1' //execute the Sha1 function on a filename before saving it (default false) ) ); validation again and it belongsTo user and band AND THE CULPRIT: egaragead class Egaragead extends AppModel { var $name = 'Egaragead'; var $actsAs = array( 'FileUpload.FileUpload' => array( 'uploadDir' => 'files/img_egarageads', 'fields' => array('name' => 'image', 'type' => 'image_type', 'size' => 'image_size'), //'allowedTypes' => array('pdf' => array('application/ pdf')), 'required' => false, //default is false, if true a validation error would occur if a file wsan't uploaded. 'maxFileSize' => '2097152', //bytes OR false to turn off maxFileSize (default false) 'unique' => true //filenames will overwrite existing files of the same name. (default true) //'fileNameFunction' => 'sha1' //execute the Sha1 function on a filename before saving it (default false) ) ); took out validation for now - no relations. On Jul 5, 6:10 pm, nurvzy wrote: > Hi Bradmax, > > First, thanks for using the plugin. Sorry to hear of your > troubles. Is your ad model the only model that is using actsAs > configuration, (ie the rest using the component?). Would you mind > showing me how you have it (and the working models) configured? > > Thanks, > Nick > > On Jul 5, 6:07 pm, bradmaxs wrote: > > > > > UPDATE: I removed the show model and it is going to another one in > > it's place. What have I done... > > > On Jul 5, 4:54 pm, bradmaxs wrote: > > > > Hi All, > > > > I have been using Nick Baker's FileUpload with much success. > > > > Except for one incredibly strange problem. > > > > I am using the plugin for about 8 models and each has a different > > > upload folder/destination. > > > > All of them are working fine except for the ad model. > > > > Initially I was having trouble getting the ads add
Re: Nick Baker's FileUpload
UPDATE: I removed the show model and it is going to another one in it's place. What have I done... On Jul 5, 4:54 pm, bradmaxs wrote: > Hi All, > > I have been using Nick Baker's FileUpload with much success. > > Except for one incredibly strange problem. > > I am using the plugin for about 8 models and each has a different > upload folder/destination. > > All of them are working fine except for the ad model. > > Initially I was having trouble getting the ads add form to upload the > image to the specified folder. The record was being saved but the > image was not getting uploaded. The show model was working great so I > copied the actsAs code and pasted in my ad model. I also changed the > path to the upload folder for the ad model. All of a sudden the images > were being uploaded to the shows destination folder even though that > is not the folder specified in my ad model??? > > For the life of me I can't figure this out. > > The ad model is using the show model's upload directory path?? > > I have tried everything. I have cleared the cache a million times. > > I removed the show model and cleared the cache and it STILL did it. > > Has anyone heard of this? Is it actsAs that is goofing me? Am I > missing something? I just can't see how I can remove the show model > with the destination path it is using (god knows why), clear all the > cache folders (models, persistent and views) and it still happens. > > I am in crazy bizzaro world. > > Please help. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Nick Baker's FileUpload
Hi All, I have been using Nick Baker's FileUpload with much success. Except for one incredibly strange problem. I am using the plugin for about 8 models and each has a different upload folder/destination. All of them are working fine except for the ad model. Initially I was having trouble getting the ads add form to upload the image to the specified folder. The record was being saved but the image was not getting uploaded. The show model was working great so I copied the actsAs code and pasted in my ad model. I also changed the path to the upload folder for the ad model. All of a sudden the images were being uploaded to the shows destination folder even though that is not the folder specified in my ad model??? For the life of me I can't figure this out. The ad model is using the show model's upload directory path?? I have tried everything. I have cleared the cache a million times. I removed the show model and cleared the cache and it STILL did it. Has anyone heard of this? Is it actsAs that is goofing me? Am I missing something? I just can't see how I can remove the show model with the destination path it is using (god knows why), clear all the cache folders (models, persistent and views) and it still happens. I am in crazy bizzaro world. Please help. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Auth Question For Webroot App
Hi Everybody, I am using the Auth component for a simple site. No ACL required. I have installed WordPress for the blogging and want to restrict users who are not signed in. I have WP installed in webroot. I thought maybe this would work but no avail. in app-controller.php if (isset($this->params['admin'])) { if ($this->Auth->user('group') == '1') { return true; } $this->Session->setFlash(__('You are not an administrator.', true)); $this->redirect(array('controller' => 'pages', 'action' => 'display', 'home', 'admin' => false)); } if (isset($this->params['blog'])) { if ($this->Auth->user('group') == '2') { return true; } $this->Session->setFlash(__('Please Register or Login to Ask A Question.', true)); $this->redirect(array('controller' => 'pages', 'action' => 'display', 'home', 'admin' => false)); } The admin function works great but can't get it to work with blog. I do have admin routing on so I imagine that is why it works there. Any suggestions on how to protect a webroot app? Thanks, Brad 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: Miles J Uploader help
Hey Miles or Anyone??, I feel like I found the problem with the uploader not accepting the birthdate array and before scrapping this uploader and moving to something different or changing the datetime field (I want to try and stick to cake's automagic form elements) I am going for one last attempt. I have logged many hours trying to figure this out and am still nowhere. I know that I keep getting an error because the birthdate is sending the info as an array to the component which is messing with the _parseData function starting on line 1006 or so in the uploader controller. So I thought I could change that data to a string to forgo the error. function afterFilter () { $birthdate = $this->data['UserPreference']['birthdate']['year'].'-'. $this->data['UserPreference']['birthdate']['month'].'-'.$this- >data['UserPreference']['birthdate']['day']; $this->data['UserPreference']['birthdate'] = $birthdate; debug($this->data); } which when I debug I do get this [UserPreference] => Array ( [user_id] => 29 [image] => resume.jpg [sex] => Male [birthdate] => 2009-06-04 [hometown] => Los Angeles [introduction] => yo ) instead of this [UserPreference] => Array ( [user_id] => 29 [image] => resume.jpg [sex] => Male [birthdate] => Array ( [day] => 04 [month] => 06 [year] => 2009 ) [hometown] => Los Angeles [introduction] => yo ) which is what I got before which I believe is the culprit. But I am still getting the error. So - the question is (and I am almost certain I am using afterFilter wrong) - how do I pass this reformatted array to the uploader component rather than the latter array which seems to be stealing the info before anything I do? Thanks again, Brad On Jun 2, 4:49 pm, bradmaxs wrote: > Hey Miles, > > Did you ever test this? > > Just checking. I am going to try and maybe do a Set::extract?? > > Going to start tomorrow but thought I would check in. > > Brad > > On May 19, 11:37 am, Miles J wrote: > > > Its probably getting confused trying to load the data since both the > > file input and date input are arrays. I dont think I have ever tested > > with a date/time input, ill try it out. > > > On May 19, 11:23 am,bradmaxs wrote: > > > > Hey Miles, > > > > That worked for a straight upload action, thank you. > > > > The Model Attachment is still not working for me though, still getting > > > the errors from the above post. > > > > After looking closer it seems that my birthdate field is doing > > > something funny?? > > > > Warning (2): Invalid argument supplied for foreach() [APP/plugins/ > > > uploader/controllers/components/uploader.php, line 1006] > > > Code | Context > > > > if (is_array($data)) { > > > foreach ($data as $model => $fields) { > > > foreach ($fields as $field => $value) { > > > > $data = array( > > > "month" => "05", > > > "day" => "19", > > > "year" => "2009" > > > ) > > > $fields = "05" > > > $model = "month" > > > > I made it a hidden field and filled in the value myself and then just > > > got this error - probably from the component? > > > > There was an error attaching this file! > > > > Any ideas? Thank you again for taking the time on this. > > > > Brad > > > > On May 18, 5:58 pm, Miles J wrote: > > > > > If you are using the latest uploader version, I believe its: > > > > > if ($data = $this->Uploader->upload('UserPreference.fileName')) { > > > > > On May 18, 11:14 am, Sam Sherlock wrote: > > > > > > Hi Brad > > > > > > It is not a compatiblity issue with 1.3 - not able to speify the > > > > > issue right > > > > > now but will try to compare your code with mine later today > > > > > > but you may solve it by then :) > > > > > - S > > > > > > On 18 May 2010 18:41,bradmaxs wrote: > > > > > > > I tried to just add it as an action in my controller and can't get a > > > > > > photo uploaded at al
Re: timeHelper
Here is a workaround for anyone who is interested. $timestamp = date("F j, Y, g:ia", strtotime(PATH-TO-DATA)); Then use $timestamp in the echo statements. Still would love to know if it is possible with the helpers though. Thanks On Jun 3, 6:17 pm, bradmaxs wrote: > Thanks Matt. > > I was wondering if there is some automagic to do this that I can > combine with niceShort. I was using that for formatting the time but > might have to use straight PHP instead. > > Thanks, > > Brad > > On Jun 2, 8:09 pm, Matthew Powell wrote: > > >http://php.net/strftime > > > Matt > > > On Wed, Jun 2, 2010 at 18:48, bradmaxs wrote: > > > Does anyone know if there is a way to convert the military time output > > > of the niceShort method to standard time? > > > > Example: 13:54:01 to 1:54pm. > > > > Thank you, > > > > Brad > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > > with their CakePHP related questions. > > > > You received this message because you are subscribed to the Google Groups > > > "CakePHP" group. > > > To post to this group, send email to cake-php@googlegroups.com > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > > athttp://groups.google.com/group/cake-php?hl=en 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: timeHelper
Thanks Matt. I was wondering if there is some automagic to do this that I can combine with niceShort. I was using that for formatting the time but might have to use straight PHP instead. Thanks, Brad On Jun 2, 8:09 pm, Matthew Powell wrote: > http://php.net/strftime > > Matt > > On Wed, Jun 2, 2010 at 18:48, bradmaxs wrote: > > Does anyone know if there is a way to convert the military time output > > of the niceShort method to standard time? > > > Example: 13:54:01 to 1:54pm. > > > Thank you, > > > Brad > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en 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: Miles J Uploader help
Hey Miles, Did you ever test this? Just checking. I am going to try and maybe do a Set::extract?? Going to start tomorrow but thought I would check in. Brad On May 19, 11:37 am, Miles J wrote: > Its probably getting confused trying to load the data since both the > file input and date input are arrays. I dont think I have ever tested > with a date/time input, ill try it out. > > On May 19, 11:23 am,bradmaxs wrote: > > > Hey Miles, > > > That worked for a straight upload action, thank you. > > > The Model Attachment is still not working for me though, still getting > > the errors from the above post. > > > After looking closer it seems that my birthdate field is doing > > something funny?? > > > Warning (2): Invalid argument supplied for foreach() [APP/plugins/ > > uploader/controllers/components/uploader.php, line 1006] > > Code | Context > > > if (is_array($data)) { > > foreach ($data as $model => $fields) { > > foreach ($fields as $field => $value) { > > > $data = array( > > "month" => "05", > > "day" => "19", > > "year" => "2009" > > ) > > $fields = "05" > > $model = "month" > > > I made it a hidden field and filled in the value myself and then just > > got this error - probably from the component? > > > There was an error attaching this file! > > > Any ideas? Thank you again for taking the time on this. > > > Brad > > > On May 18, 5:58 pm, Miles J wrote: > > > > If you are using the latest uploader version, I believe its: > > > > if ($data = $this->Uploader->upload('UserPreference.fileName')) { > > > > On May 18, 11:14 am, Sam Sherlock wrote: > > > > > Hi Brad > > > > > It is not a compatiblity issue with 1.3 - not able to speify the issue > > > > right > > > > now but will try to compare your code with mine later today > > > > > but you may solve it by then :) > > > > - S > > > > > On 18 May 2010 18:41,bradmaxs wrote: > > > > > > I tried to just add it as an action in my controller and can't get a > > > > > photo uploaded at all?? > > > > > > permissions are set to 777 on both my files folder and img_usericon as > > > > > well. > > > > > > Here is the user_preferences_controller.php > > > > > > var $components = array('Uploader.Uploader'); > > > > > > in my beforeFilter > > > > > > $this->Uploader->uploadDir = 'files/img_usericon/'; > > > > > $this->Auth->allow('upload'); > > > > > > the action > > > > > > function upload() { > > > > > if (!empty($this->data)) { > > > > > if ($data = $this->Uploader->upload('fileName')) { > > > > > $this->Session->setFlash(sprintf(__('The %s has been > > > > > saved', > > > > > true), 'user photo')); > > > > > $this->redirect(array('controller' => > > > > > 'users', 'action' => > > > > > 'profile', $this->Auth->user('id'))); > > > > > } else { > > > > > > > > > > $this->Session->setFlash(sprintf(__('The %s > > > > > could not saved', > > > > > true), 'user photo')); > > > > > $this->redirect(array('controller' => > > > > > 'users', 'action' => > > > > > 'profile', $this->Auth->user('id')));} > > > > > } > > > > > } > > > > > > and upload.ctp > > > > > > > > > > echo $this->element('errors', array('errors' => $errors)); > > > > > echo $form->create('UserPreference', array('url' => array('controller' > > > > > => 'user_preferences', 'action' =>'upload'), 'type' => 'file')); > > > > > echo $form->input('fileName', array('type' => 'file')); > > > > &
timeHelper
Does anyone know if there is a way to convert the military time output of the niceShort method to standard time? Example: 13:54:01 to 1:54pm. Thank you, Brad 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: HABTM Containable find('all') question
Hi Paul, Here in (maybe) lies the rub. There isn't an actual admirers table. There is only a friends table. The reason I am using the admirers/ friends business is to say user A has B friends and C other users have A as a friend. This was based on AD7six's reply to a 2007 post: http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc2097f8aad11/fae9ec58501534e6?tvc=2&q=friend#fae9ec58501534e6. Which is also why I set up this association. var $hasAndBelongsToMany = array( 'friend' => array('className' => 'User', 'joinTable' => 'Friend', 'foreignKey' => 'user_id', 'associationForeignKey' => 'friend_id' ), 'admirer' => array('className' => 'User', 'joinTable' =>'Friend', 'foreignKey' => 'friend_id', 'associationForeignKey' => 'user_id') ); I thought I had to do this because when I do a query to list MY friends - it is possible that I made the connection (my User.id is Friend.user_id and Friend.friend_id is the other users User.id) AND if they make the connection (their User.id is Friend.user_id and Friend.friend_id is my User.id) Then I can list both in my views and I make this a little easier for myself by doing an array_merge of the admirer and friend output of the original SQL statement. This is all working amazingly except the final piece which would be omitting anyone that has been denied by me or has denied me - because that would just be rubbing salt in the wound:) I guess the question is this. Can I get a condition from the joined tables friends and admirers ('Friend.approved !=' => '-1') to happen within the users conditions? It seems right now that if I put that condition within the joined tables conditions - the record (of the denied/denier) is still showing up - however it is leaving out the friend/admirer merged array. If I take that condition out - then the record still shows up now with this array: Array ( [0] => Array ( [id] => 4 [created] => 2010-05-03 17:33:54 [Friend] => Array ( [id] => 39 [user_id] => 4 [friend_id] => 29 [approved] => -1 [message] => [created] => 2010-05-22 12:44:05 [modified] => 2010-05-25 13:15:49 ) ) ) I hope this makes sense. I am sorry for all the text - I am just trying to wrap my head around exactly what I AM trying to do here:) Thanks again for all of your attention to this! Brad On May 29, 2:24 am, WebbedIT wrote: > Do you have access to PhpMyAdmin or something to run queries direct on > your database? > > If so try running this SQL > > SELECT DISTINCT User.id, User.username FROM users AS User > LEFT JOIN admirers AS Admirer ON (User.id = Admirer.user_id AND > Admirer.approved IN(0,1)) > LEFT JOIN friends AS Friend ON (User.id = Friend.user_id AND > Friend.approved IN(0,1)) > > Can you play with the above to see if you get the expected results and > report back to me? > > The idea here is to work out how we would do it without Cake then > structure our Model::find to produce the same SQL. > > HTH > > Paul 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: Cake 1.3 problem setting admin layout in app_controller.php
Did you ever get this to work? It is working for me in 1.3. I have in my routes: Router::connect('/admin', array('controller' => 'pages', 'action' => 'index', 'admin' => true)); Then I grabbed the pages_controller.php from cake/libs/controller and put it in my app/controllers I added: function admin_index() { } and of course I made a admin_index.ctp in views/pages. hth, Brad On May 9, 6:23 am, fabio <3bi...@gmail.com> wrote: > Hello mates, > > i'm experimenting a problem while passing from 1.2 to 1.3 regarding > how to set a style from app_controller.php > > Basicly i've a simple kind ofadminarea using the Auth component and > what i need is to set a custom style for all the views in theadmin > area: > > ie > > app/views/users/admin_add.ctp > app/views/users/admin_index.ctp > app/views/users/admin_edit.ctp > app/views/users/admin_view.ctp > > app/views/posts/admin_add.ctp > app/views/posts/admin_index.ctp > app/views/posts/admin_edit.ctp > app/views/posts/admin_view.ctp > > .. > .. > .. > > Now, to get this in Cake 1.2 I did define custom layout&style files, > like this: > > --- > app/views/layouts/admin.ctp > --- > > > > > echo $this->Html->css('admin'); > echo $scripts_for_layout; > ?> > > > > > > > > > - > app/webroot/css/admin.css > - > ... > ... > ... > > and then added the following: > > -- > app/app_controller.php > -- > > class AppController extends Controller { > > function beforeFilter() { > if (isset($this->params['admin'])) { > $this->layout= 'admin'; > } > }} > > ?> > > Strangely the same approach is not working on Cake 1.3: when I point > to anadminview i keep on seeing the default cakelayoutwith style > cake.generic.css > > Is there anybody who can see where I am wrong and why it works on 1.2 > and not on 1.3 ? > > Thanks a lot in advance > > Tres > > P.S. > Maybe it's worth to say also that i have the following line in app/ > config/routes.php: > > Router::connect('/admin', array('controller' => 'users', 'action' => > 'index', 'admin' => true)); > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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: HABTM Containable find('all') question
Hi Paul, In a nutshell, YES!! To be honest - I have spent the morning trying to understand DISTINCT having never worked with it before. I am going to start experimenting and see if I can come up with anything. I do agree, the cake community is expansive, knowledgeable and for the most part extremely helpful. Besides a few grumpy dudes out there, I completely disagree with posts that complain about the documentation for cake not being complete. The more I work with it the more I understand it. And I am starting to navigate the book like a pro. Don't necessarily understand it all the time but I could tell you where it is:) Thanks again, Brad On May 27, 1:27 am, WebbedIT wrote: > Let me clarify what we're trying to achieve here, are you after a > DISTINCT list of Users who have Friends or Admirers with an approved > status of 0 or 1? > > As for finding my posts helpful, I'm glad they have been of help, but > I can't take any credit for them as all I am doing is passing on what > I have been taught by others in the community and by constantly > reading book.cakephp.org. > > HTH > > Paul. 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: HABTM Containable find('all') question
Hi Paul, Thanks so much for getting back to me. I can tell you I have learned a lot from your posts since I have started using cake so thank you. Here is the sql statement: 23 SELECT `User`.`id`, `User`.`username`, `User`.`first_name`, `User`.`last_name`, `User`.`city`, `User`.`state`, `User`.`country`, `User`.`created`, `UserPreference`.`image` FROM `users` AS `User` LEFT JOIN `user_preferences` AS `UserPreference` ON (`UserPreference`.`user_id` = `User`.`id`) WHERE `User`.`id` != 4 ORDER BY `User`.`first_name` asc LIMIT 15 24 SELECT `friend`.`id`, `Friend`.`id`, `Friend`.`user_id`, `Friend`.`friend_id`, `Friend`.`approved`, `Friend`.`message`, `Friend`.`created`, `Friend`.`modified` FROM `users` AS `friend` JOIN `friends` AS `Friend` ON (`Friend`.`user_id` IN (3, 28, 29, 5) AND `Friend`.`friend_id` = `friend`.`id`) WHERE `friend`.`id` = 4 AND `Friend`.`approved` != -1 25 SELECT `admirer`.`id`, `admirer`.`created`, `Friend`.`id`, `Friend`.`user_id`, `Friend`.`friend_id`, `Friend`.`approved`, `Friend`.`message`, `Friend`.`created`, `Friend`.`modified` FROM `users` AS `admirer` JOIN `friends` AS `Friend` ON (`Friend`.`friend_id` IN (3, 28, 29, 5) AND `Friend`.`user_id` = `admirer`.`id`) WHERE `admirer`.`id` = 4 AND `Friend`.`approved` != -1 So, the USER record is showing up and the FRIEND array is not so actually it is right. However, I just want the USER records who's Friend.approved == 0 or 1. I put Friend.approved in the main conditions of the find() and it comes back with a 1054 Unknown Column error:) Thanks in advance. Brad On May 26, 12:13 am, WebbedIT wrote: > Have you debugged the sql queries (set debug to 2) to work out where > the sql is not being generated correctly as the condition in principle > looks correct. > > Maybe just typos but a few things look off > > 'Friend' => array( > 'conditions' => array( > 'Friend.id =' => $this->Auth->user('id'), > 'Friend.approved !=' => '-1' > ) > ), > 'Admirer' => array( > 'conditions' => array( > 'Admirer.id =' => $this->Auth->user('id'), > 'Friend.approved !=' => '-1' > ) > ), > > Friend and Admirer should be referenced with capital first letters and > there's no need to wrap conditions in AND array as that is what is > used by default. > > HTH > > Paul. > > On May 26, 1:28 am, bradmaxs wrote: > > > Hello, > > > I am working on a HABTM relationship. > > > Here is my controller action: > > > function index() { > > $this->User->Behaviors->attach('Containable'); > > $this->paginate = array( > > 'contain' => array( > > 'friend' => array( > > 'conditions' => array( > > 'friend.id =' => > > $this->Auth->user('id'), > > ) > > ), > > 'admirer' => array( > > 'conditions' => array( > > 'admirer.id =' => > > $this->Auth->user('id'), > > ) > > ), > > 'UserPreference.image' > > ), > > 'conditions' => array( > > 'User.id !=' => $this->Auth->user('id') > > ), > > 'recursive' => true, > > 'limit' => 15, > > 'order' => array( > > 'User.first_name' => 'asc' > > ) > > ); > > $users = $this->paginate('User'); > > $this->set(compact('users')); > > } > > > In my User model: > > > var $hasAndBelongsToMany = array( > > 'friend' => array('className' => 'User', > > 'joinTable' => 'Friend', > > 'foreignKey' => 'user_id', > >
HABTM Containable find('all') question
Hello, I am working on a HABTM relationship. Here is my controller action: function index() { $this->User->Behaviors->attach('Containable'); $this->paginate = array( 'contain' => array( 'friend' => array( 'conditions' => array( 'friend.id =' => $this->Auth->user('id'), ) ), 'admirer' => array( 'conditions' => array( 'admirer.id =' => $this->Auth->user('id'), ) ), 'UserPreference.image' ), 'conditions' => array( 'User.id !=' => $this->Auth->user('id') ), 'recursive' => true, 'limit' => 15, 'order' => array( 'User.first_name' => 'asc' ) ); $users = $this->paginate('User'); $this->set(compact('users')); } In my User model: var $hasAndBelongsToMany = array( 'friend' => array('className' => 'User', 'joinTable' => 'Friend', 'foreignKey' => 'user_id', 'associationForeignKey' => 'friend_id' ), 'admirer' => array('className' => 'User', 'joinTable' =>'Friend', 'foreignKey' => 'friend_id', 'associationForeignKey' => 'user_id') ); I have a column in the Friend table that has approved which is by default 0. When someone approves, they get a 1 and if someone rejects they get a -1. In my index view I would like to exclude all Friend.approved => -1. Here is the dump: Array ( [0] => Array ( [id] => 4 [username] => xxx [password] => xxx [first_name] => xxx [last_name] => xxx [street_address] => xxx [city] => xxx [state] => xxx [zip] => xxx [country] => xxx [telephone] => xxx [email_address] => xxx [group_id] => xxx [created] => 2010-05-03 17:33:54 [updated] => 2010-05-14 15:57:10 [Friend] => Array ( [id] => 39 [user_id] => 4 [friend_id] => 29 [approved] => -1 [message] => [created] => 2010-05-22 12:44:05 [modified] => 2010-05-25 13:15:49 ) ) ) If I put: 'friend' => array( 'conditions' => array( 'AND' => array( 'friend.id =' => $this->Auth->user('id'), 'Friend.approved !=' => '-1' ) ) ), 'admirer' => array( 'conditions' => array( 'AND' => array( 'admirer.id =' => $this->Auth->user('id'), 'Friend.approved !=' => '-1' ) ) ), I get this: Array ( ) So the user is still showing up, and it seems that the array is just not getting any info. I want to EXCLUDE the users who have a Friend.approved = -1. Anyone know any solutions. I thought making a sub query but it seems like it might be too much for this final exclusion. Not to mention I have worked so hard just to get here (although learning every step of the way) I don't want to mess with what I have got because the pagination works with it. Any help would be great. Thanks, Brad 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
Array Set:: Question
I have this array: [1] => Array ( [User] => Array ( [id] => 4 [username] => xxx [password] => xxx [first_name] => xxx [last_name] => xxx [street_address] => xxx [city] => xxx [state] => xxx [zip] => xxx [country] => xxx [telephone] => xxx [email_address] => xxx [group_id] => xxx [created] => xxx [updated] => xxx ) [UserPreference] => Array ( [image] => xxx ) [friend] => Array ( [0] => Array ( [id] => 29 [username] => xxx [password] => xxx [first_name] => xxx [last_name] => xxx [street_address] => xxx [city] => xxx [state] => xxx [zip] => xxx [country] => xxx [telephone] => xxx [email_address] => xxx [group_id] => xxx [created] => xxx [updated] => xxx [Friend] => Array ( [id] => 39 [user_id] => 4 [friend_id] => 29 [approved] => 0 [message] => [created] => 2010-05-22 12:44:05 [modified] => 2010-05-22 12:44:05 ) ) ) [admirer] => Array ( [0] => Array ( [id] => 5 [username] => xxx [password] => xxx [first_name] => xxx [last_name] => xxx [street_address] => xxx [city] => xxx [state] => xxx [zip] => xxx [country] => xxx [telephone] => xxx [email_address] => xxx [group_id] => xxx [created] => xxx [updated] => xxx [Friend] => Array ( [id] => 40 [user_id] => 5 [friend_id] => 4 [approved] => 0 [message] => [created] => 2010-05-22 17:50:36 [modified] => 2010-05-22 17:50:36 ) ) ) ) and I want it to look like this [1] => Array ( [User] => Array ( [id] => 4 [username] => xxx [password] => xxx [first_name] => xxx [last_name] => xxx [street_address] => xxx [city] => xxx [state] => xxx [zip] => xxx [country] => xxx [telephone] => xxx [email_address] => xxx [group_id] => xxx [created] => xxx [updated] => xxx ) [UserPreference] => Array ( [image] => xxx ) [friends] => Array ([id] => 39, [user_id] => 4, [friend_id] => 29, [approved] => 0) ([id] => 40, [user_id] => 5, [friend_id] => 4, [approved] => 0) Is this even possible with Set::extract or Set:Combine. And if so, where do I call that from, my controller. Right now I am using paginate for the find with containable to get rid of a bunch of other models. Thanks in advance. Brad 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 Group
Re: Help with User - Friend HABTM relationship
Worked like a charm! Thanks again! On May 20, 9:52 pm, bradmaxs wrote: > Thank you Calvin. Working hard to figure all of this out and your > suggestion was exactly what I was looking for. > > I will be working on this tomorrow and let you know how it works out. > > On May 20, 6:36 pm, calvin wrote: > > > > > That's a PHP question, not a Cake question. > > > If you want to combine the arrays, then just combine them like you > > would any other array. > > > If you have: > > > $friends = array('friend 1', 'friend 2', 'friend 3', ...); > > $admirers = array('admirer 1', 'admirer 2', 'admirer 3', ...); > > > how would you combine them? > > > Well, the obvious solution is with array_merge(): > > $friendsAndAdmirers = array_merge($friends, $admirers); > > > If you want to filter out duplicates (i.e. if a person is both a > > friend and an admirer), then use array_unique() on top of > > array_merge(). > > > I would suggest bookmarking--or, better yet, installing the Firefox > > search tool for--the PHP Manual:http://us3.php.net/manual/en/index.php > > > On May 20, 11:31 am, bradmaxs wrote: > > > > Anyone able to help me on this? > > > > On May 18, 4:55 pm, bradmaxs wrote: > > > > > Hello All, > > > > > In response to the following post: > > > > >http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209... > > > > > I have come up with my users having friends and admirers, thank you > > > > gentlemen for that. > > > > > I am getting the array for both of them in my dump. > > > > > [friend] => Array > > > > ( > > > > [0] => Array > > > > ( > > > > [id] => 3 > > > > [username] => artist > > > > > [Friend] => Array > > > > ( > > > > [id] => 1 > > > > [user_id] => 4 > > > > [friend_id] => 3 > > > > [approved] => 1 > > > > ) > > > > > ) > > > > > [1] => Array > > > > ( > > > > [id] => 5 > > > > [username] => testing > > > > > [Friend] => Array > > > > ( > > > > [id] => 2 > > > > [user_id] => 4 > > > > [friend_id] => 5 > > > > [approved] => 1 > > > > ) > > > > > ) > > > > > ) > > > > > [admirer] => Array > > > > ( > > > > [0] => Array > > > > ( > > > > [id] => 5 > > > > [username] => testing > > > > > [Friend] => Array > > > > ( > > > > [id] => 3 > > > > [user_id] => 5 > > > > [friend_id] => 4 > > > > [approved] => 0 > > > > > My question, and I think it is simple but I am still a newbie for the > > > > most part - > > > > > How do I combine that data in the view to have both friends and > > > > admirers as part of the same foreach statement? > > > > > Is that possible? I have looked at Set::merge and tried that from the > > > > controller. Looked at custom query methods but the data is already > > > > there in an array so I am a little stuck. > > > > > Here is what is in my view for the friends array and it is working > > > > fine. Just don't know how to get the admirer as part of it. > > > > > > > > > > > > > > > > > Html->link(__('View', true), array('controller' => > > > > 'friends', 'action' => 'view', $friend['id'])); ?> > > > > Html->link(__('Delete', tr
Re: Find Question - field()
Thanks Calvin. I get it. On May 20, 8:44 pm, calvin wrote: > I mean referencing the model object itself, i.e. $this->User->find() > instead of $model->find() or User->find(). > > On May 20, 10:18 am, bradmaxs wrote: > > > > > Thanks Calvin. > > > When you say access models from controllers, do you mean with find(). > > > Trying some different methods as we speak. > > > On May 20, 4:07 am, calvin wrote: > > > > Assuming that's exactly what your code looks like, the > > > T_OBJECT_OPERATOR error is probably because you're putting a > > > T_OBJECT_OPERATOR ("->") after a constant ("User"). If you want the > > > model, then you need to write $this->User. Likewise, unless you > > > declared a variable previously named $model, calling $model- > > > > >anything() is going to result in an error. > > > > Jeremy's recommendations are good, but you should still read up on how > > > to access models from controllers in the Cookbook. That will help you > > > avoid encountering similar errors in the future. > > > > On May 19, 7:17 pm, bradmaxs wrote: > > > > > I want to send an email with the email component. No problem there. > > > > > However, I don't want it to be a hidden field in the form so I thought > > > > I could do something in the controller. > > > > > So I did this line: > > > > > $email = $this->User->find('first', array('conditions' => > > > > array('User.id' => $this->data['Friend']['friend_id']), 'fields' => > > > > 'User.email_address')); > > > > > Which to my surprise (still learning all of these functions) it did > > > > get the email address but the find function turns the info into an > > > > array and then the email component has an array to deal with rather > > > > than the specific string (email_address). > > > > > I thought I could use the field() method but I am confused as to how > > > > to get it to work and there isn't much documentation. > > > > > I tried: > > > > > $email = User->field('email_address', array('id' => $this- > > > > > >data['Friend']['friend_id'])); > > > > > and got: > > > > > Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/ > > > > vhosts/theactorstoolkit.com/httpdocs/app/controllers/ > > > > users_controller.php on line 69 > > > > > which shows up on the screen before I even get to the page. > > > > > I tried: > > > > > $email = $model->field('email_address', array('id' => $this- > > > > > >data['Friend']['friend_id'])); > > > > > and once I submit the form it gives me: > > > > > Notice (8): Undefined variable: model [APP/controllers/ > > > > users_controller.php, line 69] > > > > > Anyone know how this should be done. > > > > > Thank you! > > > > > Brad > > > > > Check out the new CakePHP Questions > > > > sitehttp://cakeqs.organdhelpotherswith their CakePHP related questions. > > > > > You received this message because you are subscribed to the Google > > > > Groups "CakePHP" group. > > > > To post to this group, send email to cake-php@googlegroups.com > > > > To unsubscribe from this group, send email to > > > > cake-php+unsubscr...@googlegroups.com For more options, visit this > > > > group athttp://groups.google.com/group/cake-php?hl=en > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers > > > with their CakePHP related questions. > > > > You received this message because you are subscribed to the Google Groups > > > "CakePHP" group. > > > To post to this group, send email to cake-php@googlegroups.com > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > > athttp://groups.google.com/group/cake-php?hl=en > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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@go
Re: Help with User - Friend HABTM relationship
Thank you Calvin. Working hard to figure all of this out and your suggestion was exactly what I was looking for. I will be working on this tomorrow and let you know how it works out. On May 20, 6:36 pm, calvin wrote: > That's a PHP question, not a Cake question. > > If you want to combine the arrays, then just combine them like you > would any other array. > > If you have: > > $friends = array('friend 1', 'friend 2', 'friend 3', ...); > $admirers = array('admirer 1', 'admirer 2', 'admirer 3', ...); > > how would you combine them? > > Well, the obvious solution is with array_merge(): > $friendsAndAdmirers = array_merge($friends, $admirers); > > If you want to filter out duplicates (i.e. if a person is both a > friend and an admirer), then use array_unique() on top of > array_merge(). > > I would suggest bookmarking--or, better yet, installing the Firefox > search tool for--the PHP Manual:http://us3.php.net/manual/en/index.php > > On May 20, 11:31 am, bradmaxs wrote: > > > > > Anyone able to help me on this? > > > On May 18, 4:55 pm, bradmaxs wrote: > > > > Hello All, > > > > In response to the following post: > > > >http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209... > > > > I have come up with my users having friends and admirers, thank you > > > gentlemen for that. > > > > I am getting the array for both of them in my dump. > > > > [friend] => Array > > > ( > > > [0] => Array > > > ( > > > [id] => 3 > > > [username] => artist > > > > [Friend] => Array > > > ( > > > [id] => 1 > > > [user_id] => 4 > > > [friend_id] => 3 > > > [approved] => 1 > > > ) > > > > ) > > > > [1] => Array > > > ( > > > [id] => 5 > > > [username] => testing > > > > [Friend] => Array > > > ( > > > [id] => 2 > > > [user_id] => 4 > > > [friend_id] => 5 > > > [approved] => 1 > > > ) > > > > ) > > > > ) > > > > [admirer] => Array > > > ( > > > [0] => Array > > > ( > > > [id] => 5 > > > [username] => testing > > > > [Friend] => Array > > > ( > > > [id] => 3 > > > [user_id] => 5 > > > [friend_id] => 4 > > > [approved] => 0 > > > > My question, and I think it is simple but I am still a newbie for the > > > most part - > > > > How do I combine that data in the view to have both friends and > > > admirers as part of the same foreach statement? > > > > Is that possible? I have looked at Set::merge and tried that from the > > > controller. Looked at custom query methods but the data is already > > > there in an array so I am a little stuck. > > > > Here is what is in my view for the friends array and it is working > > > fine. Just don't know how to get the admirer as part of it. > > > > > > > > > > > > > Html->link(__('View', true), array('controller' => > > > 'friends', 'action' => 'view', $friend['id'])); ?> > > > Html->link(__('Delete', true), array('controller' => > > > 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are > > > you sure you want to delete # %s?', true), $friend['id'])); ?> > > > > > > > Thanks for any help! > > > > Brad > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers > > > with their CakePHP related questions. > >
Re: Help with User - Friend HABTM relationship
Anyone able to help me on this? On May 18, 4:55 pm, bradmaxs wrote: > Hello All, > > In response to the following post: > > http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209... > > I have come up with my users having friends and admirers, thank you > gentlemen for that. > > I am getting the array for both of them in my dump. > > [friend] => Array > ( > [0] => Array > ( > [id] => 3 > [username] => artist > > [Friend] => Array > ( > [id] => 1 > [user_id] => 4 > [friend_id] => 3 > [approved] => 1 > ) > > ) > > [1] => Array > ( > [id] => 5 > [username] => testing > > [Friend] => Array > ( > [id] => 2 > [user_id] => 4 > [friend_id] => 5 > [approved] => 1 > ) > > ) > > ) > > [admirer] => Array > ( > [0] => Array > ( > [id] => 5 > [username] => testing > > [Friend] => Array > ( > [id] => 3 > [user_id] => 5 > [friend_id] => 4 > [approved] => 0 > > My question, and I think it is simple but I am still a newbie for the > most part - > > How do I combine that data in the view to have both friends and > admirers as part of the same foreach statement? > > Is that possible? I have looked at Set::merge and tried that from the > controller. Looked at custom query methods but the data is already > there in an array so I am a little stuck. > > Here is what is in my view for the friends array and it is working > fine. Just don't know how to get the admirer as part of it. > > > > > Html->link(__('View', true), array('controller' => > 'friends', 'action' => 'view', $friend['id'])); ?> > Html->link(__('Delete', true), array('controller' => > 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are > you sure you want to delete # %s?', true), $friend['id'])); ?> > > > Thanks for any help! > > Brad > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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: Find Question - field()
Thanks Calvin. When you say access models from controllers, do you mean with find(). Trying some different methods as we speak. On May 20, 4:07 am, calvin wrote: > Assuming that's exactly what your code looks like, the > T_OBJECT_OPERATOR error is probably because you're putting a > T_OBJECT_OPERATOR ("->") after a constant ("User"). If you want the > model, then you need to write $this->User. Likewise, unless you > declared a variable previously named $model, calling $model- > > >anything() is going to result in an error. > > Jeremy's recommendations are good, but you should still read up on how > to access models from controllers in the Cookbook. That will help you > avoid encountering similar errors in the future. > > On May 19, 7:17 pm, bradmaxs wrote: > > > > > I want to send an email with the email component. No problem there. > > > However, I don't want it to be a hidden field in the form so I thought > > I could do something in the controller. > > > So I did this line: > > > $email = $this->User->find('first', array('conditions' => > > array('User.id' => $this->data['Friend']['friend_id']), 'fields' => > > 'User.email_address')); > > > Which to my surprise (still learning all of these functions) it did > > get the email address but the find function turns the info into an > > array and then the email component has an array to deal with rather > > than the specific string (email_address). > > > I thought I could use the field() method but I am confused as to how > > to get it to work and there isn't much documentation. > > > I tried: > > > $email = User->field('email_address', array('id' => $this- > > > >data['Friend']['friend_id'])); > > > and got: > > > Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/ > > vhosts/theactorstoolkit.com/httpdocs/app/controllers/ > > users_controller.php on line 69 > > > which shows up on the screen before I even get to the page. > > > I tried: > > > $email = $model->field('email_address', array('id' => $this- > > > >data['Friend']['friend_id'])); > > > and once I submit the form it gives me: > > > Notice (8): Undefined variable: model [APP/controllers/ > > users_controller.php, line 69] > > > Anyone know how this should be done. > > > Thank you! > > > Brad > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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: Find Question - field()
Thank you, thank you, thank you!! I put it in my controller tonight and it worked like a charm. I am going to try the model method tomorrow and I will let you know how that goes. Brad On May 19, 10:52 pm, Jeremy Burns wrote: > Thanks... > > Well that seems a fairly simple array. You could either make it a function in > your User model: > > function emailAddress($id = null) { > > if (!$id) return ""; > > $this->id = $id; > return $this->User->field('email_address'); > > } > > This ought to return the email address for the user with an id of $id. > You call it like this: $email = $this->User->emailAddress($friend_id); > > The advantage of this is that you could add extra code later on and that will > get applied wherever you call it. > > Or you could just leave it as inline code: > > $email = $this->User->field( > 'email_address', > array('id' => $this->data['Friend']['friend_id']) > ); > > I think you had two error in your code. I have replaced User-> with > $this->User-> and there was a '>' missing inside $this->data. > > Jeremy Burns > jeremybu...@me.com > > On 20 May 2010, at 06:31, bradmaxs wrote: > > > > > Wow - Jeremy you are the man with many awesome suggestions. > > > This is my first BIG project using cake (which is amazing) so I am > > trying to do it all. I thought I would get the app working and then > > go back and add all the goodies. It seems every time I look through > > the book (1 million times a day) I find yet another method I will need > > to add. Ugh:) > > > Right now I am focusing on my User model. Anyway - I digress. > > > Here is the array: > > > Array > > ( > > [User] => Array > > ( > > [email_address] => b...@domain.com > > [id] => 28 > > ) > > > Jeremy - thank you for the time. I do appreciate you and everyone on > > this site for that matter for all of the guidance and look forward to > > the day I can help newbies. > > > Brad > > > On May 19, 9:49 pm, Jeremy Burns wrote: > >> Cake find results are always (he says, sticking his neck out!) arrays, so > >> even if you cracked your second challenge, you're still going to get an > >> array. I'd suggest refining the first find example (as it works) so that > >> the resulting array is smaller. > > >> Can you post the contents of the array here? Use - die(debug($email)); - > >> to get the contents. I notice that you are not using either recursive or > >> the Containable behaviour. We might be able to advise you how to > >> incorporate those. > > >> I'd probably also suggest making this a model function, and let the model > >> strip out the value you need from the array and return a single value. > > >> Jeremy Burns > >> jeremybu...@me.com > > >> On 20 May 2010, at 03:17, bradmaxs wrote: > > >>> I want to send an email with the email component. No problem there. > > >>> However, I don't want it to be a hidden field in the form so I thought > >>> I could do something in the controller. > > >>> So I did this line: > > >>> $email = $this->User->find('first', array('conditions' => > >>> array('User.id' => $this->data['Friend']['friend_id']), 'fields' => > >>> 'User.email_address')); > > >>> Which to my surprise (still learning all of these functions) it did > >>> get the email address but the find function turns the info into an > >>> array and then the email component has an array to deal with rather > >>> than the specific string (email_address). > > >>> I thought I could use the field() method but I am confused as to how > >>> to get it to work and there isn't much documentation. > > >>> I tried: > > >>> $email = User->field('email_address', array('id' => $this- > >>>> data['Friend']['friend_id'])); > > >>> and got: > > >>> Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/ > >>> vhosts/theactorstoolkit.com/httpdocs/app/controllers/ > >>> users_controller.php on line 69 > > >>> which shows up on the screen before I even get to the page. > > >>> I tried: > > >>
Re: Find Question - field()
Wow - Jeremy you are the man with many awesome suggestions. This is my first BIG project using cake (which is amazing) so I am trying to do it all. I thought I would get the app working and then go back and add all the goodies. It seems every time I look through the book (1 million times a day) I find yet another method I will need to add. Ugh:) Right now I am focusing on my User model. Anyway - I digress. Here is the array: Array ( [User] => Array ( [email_address] => b...@domain.com [id] => 28 ) Jeremy - thank you for the time. I do appreciate you and everyone on this site for that matter for all of the guidance and look forward to the day I can help newbies. Brad On May 19, 9:49 pm, Jeremy Burns wrote: > Cake find results are always (he says, sticking his neck out!) arrays, so > even if you cracked your second challenge, you're still going to get an > array. I'd suggest refining the first find example (as it works) so that the > resulting array is smaller. > > Can you post the contents of the array here? Use - die(debug($email)); - to > get the contents. I notice that you are not using either recursive or the > Containable behaviour. We might be able to advise you how to incorporate > those. > > I'd probably also suggest making this a model function, and let the model > strip out the value you need from the array and return a single value. > > Jeremy Burns > jeremybu...@me.com > > On 20 May 2010, at 03:17, bradmaxs wrote: > > > > > I want to send an email with the email component. No problem there. > > > However, I don't want it to be a hidden field in the form so I thought > > I could do something in the controller. > > > So I did this line: > > > $email = $this->User->find('first', array('conditions' => > > array('User.id' => $this->data['Friend']['friend_id']), 'fields' => > > 'User.email_address')); > > > Which to my surprise (still learning all of these functions) it did > > get the email address but the find function turns the info into an > > array and then the email component has an array to deal with rather > > than the specific string (email_address). > > > I thought I could use the field() method but I am confused as to how > > to get it to work and there isn't much documentation. > > > I tried: > > > $email = User->field('email_address', array('id' => $this- > >> data['Friend']['friend_id'])); > > > and got: > > > Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/ > > vhosts/theactorstoolkit.com/httpdocs/app/controllers/ > > users_controller.php on line 69 > > > which shows up on the screen before I even get to the page. > > > I tried: > > > $email = $model->field('email_address', array('id' => $this- > >> data['Friend']['friend_id'])); > > > and once I submit the form it gives me: > > > Notice (8): Undefined variable: model [APP/controllers/ > > users_controller.php, line 69] > > > Anyone know how this should be done. > > > Thank you! > > > Brad > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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
Find Question - field()
I want to send an email with the email component. No problem there. However, I don't want it to be a hidden field in the form so I thought I could do something in the controller. So I did this line: $email = $this->User->find('first', array('conditions' => array('User.id' => $this->data['Friend']['friend_id']), 'fields' => 'User.email_address')); Which to my surprise (still learning all of these functions) it did get the email address but the find function turns the info into an array and then the email component has an array to deal with rather than the specific string (email_address). I thought I could use the field() method but I am confused as to how to get it to work and there isn't much documentation. I tried: $email = User->field('email_address', array('id' => $this- >data['Friend']['friend_id'])); and got: Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/ vhosts/theactorstoolkit.com/httpdocs/app/controllers/ users_controller.php on line 69 which shows up on the screen before I even get to the page. I tried: $email = $model->field('email_address', array('id' => $this- >data['Friend']['friend_id'])); and once I submit the form it gives me: Notice (8): Undefined variable: model [APP/controllers/ users_controller.php, line 69] Anyone know how this should be done. Thank you! Brad 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: Miles J Uploader help
Hey Miles, That worked for a straight upload action, thank you. The Model Attachment is still not working for me though, still getting the errors from the above post. After looking closer it seems that my birthdate field is doing something funny?? Warning (2): Invalid argument supplied for foreach() [APP/plugins/ uploader/controllers/components/uploader.php, line 1006] Code | Context if (is_array($data)) { foreach ($data as $model => $fields) { foreach ($fields as $field => $value) { $data = array( "month" => "05", "day" => "19", "year" => "2009" ) $fields = "05" $model = "month" I made it a hidden field and filled in the value myself and then just got this error - probably from the component? There was an error attaching this file! Any ideas? Thank you again for taking the time on this. Brad On May 18, 5:58 pm, Miles J wrote: > If you are using the latest uploader version, I believe its: > > if ($data = $this->Uploader->upload('UserPreference.fileName')) { > > On May 18, 11:14 am, Sam Sherlock wrote: > > > Hi Brad > > > It is not a compatiblity issue with 1.3 - not able to speify the issue right > > now but will try to compare your code with mine later today > > > but you may solve it by then :) > > - S > > > On 18 May 2010 18:41, bradmaxs wrote: > > > > I tried to just add it as an action in my controller and can't get a > > > photo uploaded at all?? > > > > permissions are set to 777 on both my files folder and img_usericon as > > > well. > > > > Here is the user_preferences_controller.php > > > > var $components = array('Uploader.Uploader'); > > > > in my beforeFilter > > > > $this->Uploader->uploadDir = 'files/img_usericon/'; > > > $this->Auth->allow('upload'); > > > > the action > > > > function upload() { > > > if (!empty($this->data)) { > > > if ($data = $this->Uploader->upload('fileName')) { > > > $this->Session->setFlash(sprintf(__('The %s has been > > > saved', > > > true), 'user photo')); > > > $this->redirect(array('controller' => > > > 'users', 'action' => > > > 'profile', $this->Auth->user('id'))); > > > } else { > > > $this->Session->setFlash(sprintf(__('The > > > %s > > > could not saved', > > > true), 'user photo')); > > > $this->redirect(array('controller' => > > > 'users', 'action' => > > > 'profile', $this->Auth->user('id')));} > > > } > > > } > > > > and upload.ctp > > > > > > echo $this->element('errors', array('errors' => $errors)); > > > echo $form->create('UserPreference', array('url' => array('controller' > > > => 'user_preferences', 'action' =>'upload'), 'type' => 'file')); > > > echo $form->input('fileName', array('type' => 'file')); > > > echo $form->end('Upload'); > > > ?> > > > > Not sure what I am doing wrong. Could it be 1.3? > > > > It is sending me back to my else redirect and giving me my not saved > > > message? > > > > Thanks for any help. > > > > Brad > > > > On May 17, 11:05 pm, Miles J wrote: > > > > Let me do a few local tests. In the mean time, take a look at the > > > > example controller in the plugin. > > > > > On May 17, 9:52 pm, bradmaxs wrote: > > > > > > Hey Miles, > > > > > > Thanks for the fast reply. For some reason i am only seeing your last > > > > > post. Google groups is acting funny for me. I saw in the email > > > > > summary that you left 2 messages but only see the one here. I did see > > > > > in the email summary that the first post you said I didn't need this > > > > > in my controller if ($data = $this->Uploader->upload('image')) { so I > > > > > took that out and also made the change to the attachment array to > > > > &g
Help with User - Friend HABTM relationship
Hello All, In response to the following post: http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc2097f8aad11/fae9ec58501534e6?lnk=gst&q=friend#fae9ec58501534e6 I have come up with my users having friends and admirers, thank you gentlemen for that. I am getting the array for both of them in my dump. [friend] => Array ( [0] => Array ( [id] => 3 [username] => artist [Friend] => Array ( [id] => 1 [user_id] => 4 [friend_id] => 3 [approved] => 1 ) ) [1] => Array ( [id] => 5 [username] => testing [Friend] => Array ( [id] => 2 [user_id] => 4 [friend_id] => 5 [approved] => 1 ) ) ) [admirer] => Array ( [0] => Array ( [id] => 5 [username] => testing [Friend] => Array ( [id] => 3 [user_id] => 5 [friend_id] => 4 [approved] => 0 My question, and I think it is simple but I am still a newbie for the most part - How do I combine that data in the view to have both friends and admirers as part of the same foreach statement? Is that possible? I have looked at Set::merge and tried that from the controller. Looked at custom query methods but the data is already there in an array so I am a little stuck. Here is what is in my view for the friends array and it is working fine. Just don't know how to get the admirer as part of it. Html->link(__('View', true), array('controller' => 'friends', 'action' => 'view', $friend['id'])); ?> Html->link(__('Delete', true), array('controller' => 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $friend['id'])); ?> Thanks for any help! Brad 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: Miles J Uploader help
I tried to just add it as an action in my controller and can't get a photo uploaded at all?? permissions are set to 777 on both my files folder and img_usericon as well. Here is the user_preferences_controller.php var $components = array('Uploader.Uploader'); in my beforeFilter $this->Uploader->uploadDir = 'files/img_usericon/'; $this->Auth->allow('upload'); the action function upload() { if (!empty($this->data)) { if ($data = $this->Uploader->upload('fileName')) { $this->Session->setFlash(sprintf(__('The %s has been saved', true), 'user photo')); $this->redirect(array('controller' => 'users', 'action' => 'profile', $this->Auth->user('id'))); } else { $this->Session->setFlash(sprintf(__('The %s could not saved', true), 'user photo')); $this->redirect(array('controller' => 'users', 'action' => 'profile', $this->Auth->user('id')));} } } and upload.ctp element('errors', array('errors' => $errors)); echo $form->create('UserPreference', array('url' => array('controller' => 'user_preferences', 'action' =>'upload'), 'type' => 'file')); echo $form->input('fileName', array('type' => 'file')); echo $form->end('Upload'); ?> Not sure what I am doing wrong. Could it be 1.3? It is sending me back to my else redirect and giving me my not saved message? Thanks for any help. Brad On May 17, 11:05 pm, Miles J wrote: > Let me do a few local tests. In the mean time, take a look at the > example controller in the plugin. > > On May 17, 9:52 pm, bradmaxs wrote: > > > Hey Miles, > > > Thanks for the fast reply. For some reason i am only seeing your last > > post. Google groups is acting funny for me. I saw in the email > > summary that you left 2 messages but only see the one here. I did see > > in the email summary that the first post you said I didn't need this > > in my controller if ($data = $this->Uploader->upload('image')) { so I > > took that out and also made the change to the attachment array to > > 'image'. Should of caught that one myself but didn't so thank you. > > > Now I am getting a bunch of errors - maybe this will help. > > > Warning (2): Invalid argument supplied for foreach() [APP/plugins/ > > uploader/controllers/components/uploader.php, line 1006] > > Code | Context > > > if (is_array($data)) { > > foreach ($data as $model => $fields) { > > foreach ($fields as $field => $value) { > > > $data = array( > > "month" => "05", > > "day" => "17", > > "year" => "2009" > > ) > > $fields = "05" > > $model = "month" > > > UploaderComponent::__parseData() - APP/plugins/uploader/controllers/ > > components/uploader.php, line 1006 > > UploaderComponent::__parseData() - APP/plugins/uploader/controllers/ > > components/uploader.php, line 1016 > > UploaderComponent::initialize() - APP/plugins/uploader/controllers/ > > components/uploader.php, line 185 > > Component::initialize() - CORE/cake/libs/controller/component.php, > > line 98 > > Controller::startupProcess() - CORE/cake/libs/controller/ > > controller.php, line 525 > > Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187 > > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 > > [main] - APP/webroot/index.php, line 83 > > > Notice (8): Array to string conversion [CORE/cake/libs/model/ > > datasources/dbo_source.php, line 731] > > Code | Context > > > $model = UserPreference > > UserPreference::$name = "UserPreference" > > UserPreference::$validate = array > > UserPreference::$belongsTo = array > > UserPreference::$useDbConfig = "default" > > UserPreference::$useTable = "user_preferences" > > UserPreference::$displayField = "id" > > UserPreference::$id = false > > UserPreference::$data = array > > UserPreference::$table = "user_preferences" > > UserPreference::$primaryKey = "id" > > UserPreference::$_schema = array > > UserPreference::$validationErrors = array > >
Re: Miles J Uploader help
ernal], line ?? DboSource::create() - CORE/cake/libs/model/datasources/dbo_source.php, line 731 Model::save() - CORE/cake/libs/model/model.php, line 1335 UserPreferencesController::add() - APP/controllers/ user_preferences_controller.php, line 41 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 666] Code | Context $out = null; if ($error) { trigger_error('' . __('SQL Error:', true) . " {$this->error}", E_USER_WARNING); $sql= "INSERT INTO `user_preferences` (`user_id`, `sex`, `birthdate`, `hometown`, `introduction`, `image`, `modified`, `created`) VALUES (5, 'Male', '2009-05-17', 'Los Angeles', 'Yo', Array, '2010-05-17 21:49:24', '2010-05-17 21:49:24')" $error = "1054: Unknown column 'Array' in 'field list'" $out= null DboSource::showQuery() - CORE/cake/libs/model/datasources/ dbo_source.php, line 666 DboSource::execute() - CORE/cake/libs/model/datasources/ dbo_source.php, line 256 DboSource::create() - CORE/cake/libs/model/datasources/dbo_source.php, line 734 Model::save() - CORE/cake/libs/model/model.php, line 1335 UserPreferencesController::add() - APP/controllers/ user_preferences_controller.php, line 41 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 Query: INSERT INTO `user_preferences` (`user_id`, `sex`, `birthdate`, `hometown`, `introduction`, `image`, `modified`, `created`) VALUES (5, 'Male', '2009-05-17', 'Los Angeles', 'Yo', Array, '2010-05-17 21:49:24', '2010-05-17 21:49:24') Seems like the array of image info isn't getting parsed? Thanks for taking the time Miles. Brad On May 17, 8:11 pm, Miles J wrote: > Also forgot to say, this line should be "image" instead of "file", > since thats what you called it with the form helper. > > 'Uploader.Attachment' => array( > 'image' => array( > > On May 17, 7:57 pm, bradmaxs wrote: > > > > > I am trying to implement miles j's uploader plugin and am having > > trouble making it work. > > > I keep getting this error: Warning (2): Invalid argument supplied for > > foreach() [APP/plugins/uploader/controllers/components/uploader.php, > > line 1006] > > > First and foremost I am using cakephp version 1.3 so I am not sure > > this is related because the plugin is tested through 1.2 something. > > > Here is what I did so far. > > > Added the uploader folder to the plugins folder. > > > Added this to my user_preferences_controller.php: > > > var $components = array('Uploader.Uploader'); > > > var $actsAs = array( > > 'Uploader.Attachment' => array( > > 'file' => array( > > 'uploadDir' => '/files/img_usericon/', // Where to > > upload > > to, relative to app webroot > > 'dbColumn' => 'image', // The database column name to > > save the path to > > 'maxNameLength' => 30, // Max file name length > > 'overwrite' => true, // Overwrite file with same > > name if > > it exists > > 'name' => '', // The name to give > > the file (should be > > done right before a save) > > 'transforms' => array() // What transformations to do > > on > > images: scale, resize, etc > > ) > > ) > > ); > > > Made my files folder 777. Is this bad to do? > > > And my add action > > > function add($id = null) { > > if (!empty($this->data)) { > > $this->UserPreference->create(); > > if ($data = $this->Uploader->upload('image')) { > > if ($this->UserPreference->save($this->data)) { > > $this->Session->setFlash(sprintf(__('The %s > > has been saved', > > true), 'user preference')); > > $this->redirect(array('controller' => > > 'users', '
Miles J Uploader help
I am trying to implement miles j's uploader plugin and am having trouble making it work. I keep getting this error: Warning (2): Invalid argument supplied for foreach() [APP/plugins/uploader/controllers/components/uploader.php, line 1006] First and foremost I am using cakephp version 1.3 so I am not sure this is related because the plugin is tested through 1.2 something. Here is what I did so far. Added the uploader folder to the plugins folder. Added this to my user_preferences_controller.php: var $components = array('Uploader.Uploader'); var $actsAs = array( 'Uploader.Attachment' => array( 'file' => array( 'uploadDir' => '/files/img_usericon/', // Where to upload to, relative to app webroot 'dbColumn' => 'image', // The database column name to save the path to 'maxNameLength' => 30, // Max file name length 'overwrite' => true,// Overwrite file with same name if it exists 'name' => '', // The name to give the file (should be done right before a save) 'transforms'=> array() // What transformations to do on images: scale, resize, etc ) ) ); Made my files folder 777. Is this bad to do? And my add action function add($id = null) { if (!empty($this->data)) { $this->UserPreference->create(); if ($data = $this->Uploader->upload('image')) { if ($this->UserPreference->save($this->data)) { $this->Session->setFlash(sprintf(__('The %s has been saved', true), 'user preference')); $this->redirect(array('controller' => 'users', 'action' => 'profile', $this->Auth->user('id'))); } else { $this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), 'user preference')); } } } And my add.ctp Form->create('UserPreference', array('enctype' => 'multipart/form-data'));?> Form->hidden('user_id', array('value' => $loggedin['User']['id'])); echo $this->Form->input('image', array('type' => 'file', 'label' => 'Upload Image', 'error' => false)); echo $this->Form->input('sex', array('options' => array('Male' =>'Male', 'Female' => 'Female'), 'error' => false)); echo $this->Form->input('birthdate', array('type' => 'date', 'minYear' => 1925, 'maxYear' => 2009, 'error' => false)); echo $this->Form->input('hometown', array('error' => false)); echo $this->Form->input('introduction', array('error' => false)); ?> Form->end(__('Submit', true));?> } I am confused if I NEED validation for it to work or not. I ultimately want the user to be able to add preferences and upload the file at the same time and when the file is uploaded I want the UserPreference Model's image column to reflect the images name. If I can get this to work I then want to resize and possibly make changes to the image. Is this possible with this plugin or should I look for something else? Thank you, Brad 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: 2 models in one view
Thank you Zaky. Makes perfect sense. On May 14, 12:28 pm, Zaky Katalan-Ezra wrote: > As you can see from the cookbook > profile.user_id should define hasOne and post.user_id should define hasMany. > There is no way the "./cake bake all" can distinguish these two so by > default its hasMany. > If you want to define hasOne set it manually or bake the model step by step > and choose user hasOne reference. > > I think that if you defined a unique index on profile.user_id and aforeign > key cake should use hasOne. > But it doesn't. > > > > On Fri, May 14, 2010 at 8:55 PM, bradmaxs wrote: > > Thank you both for your responses. > > > I ended up changing the association, cleared my cache and it works > > like a charm. > > > Quick question. I used the command line to bake everything. The > > user_preference table has user_id in it for the association. > > > Why did bake make it a hasMany association rather than hasOne? Did I > > miss something when I baked the models? > > > Thanks again. > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.comFor > > more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en > > -- > Regards, > Zaky Katalan-Ezra > QA Administratorwww.IGeneriX.com > Sites.IGeneriX.com > 054-7762312 > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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: 2 models in one view
Thank you both for your responses. I ended up changing the association, cleared my cache and it works like a charm. Quick question. I used the command line to bake everything. The user_preference table has user_id in it for the association. Why did bake make it a hasMany association rather than hasOne? Did I miss something when I baked the models? Thanks again. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
2 models in one view
I know this is probably simple but I have spent a lot of time trying to figure this out and was hoping someone could assist. I have a user model and a user_preference model. user_preference belongs to user. I am in view.ctp of the user model and in the dump I have the following array. Array ( [User] => Array ( [id] => 4 [username] => bradmaxs [password] => [first_name] => Bradley [last_name] => Mackenzie [street_address] => [city] => [state] => [zip] => [country] => USA [telephone] => [email_address] => [group_id] => 1 [created] => 2010-05-03 17:33:54 [updated] => 2010-05-09 19:53:35 ) [UserPreference] => Array ( [0] => Array ( [id] => 1 [user_id] => 4 [image] => bradmaxs.jpg [sex] => Male [birthdate] => [hometown] => Pittsburgh [introduction] => [created] => 2010-05-10 19:32:19 [modified] => 2010-05-13 17:33:35 ) ) ) To display info for the user data it baked: $user['User']['username']; and this works great displaying the user model data. Then I want to display the user_preference data as well. It works great this way: Html->link(sprintf(__('Edit %s', true), __('User Preference', true)), array('controller' => 'user_preferences', 'action' => 'edit', $userPreference['id'])); ?> But I want to take it out of the foreach loop and include it mixed within the user model data. I have a lot of other models with relational data that I will need to do the same and I know there must be a way to do this without foreach everytime. I tried $user['UserPreference']['image'] and it is saying - : Undefined index: image. Any ideas? Thanks in advance, Brad 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: array dump
Thanks - I guess I misread the post about it being deprecated. Works now! On May 10, 6:51 pm, Andy Dirnberger wrote: > http://book.cakephp.org/view/1128/debug > > On May 10, 9:06 pm, bradmaxs wrote: > > > > > Can anyone tell me how to get: > > > Array > > ( > > [0] => Array > > ( > > [Portfolio] => Array > > ( > > [id] => 1 > > [user_id] => 0 > > [url] => 29thstreetrep.com > > [description] => Off-Broadway New York City > > theater company known for its brutal play selections. > > [domain_start] => 1999-08-02 > > [domain_expire] => 2011-08-02 > > [domain_owner] => David Mogentale > > [host] => BMCO > > [category] => theatre > > [status] => current > > [img] => portfolio_29thstreetrep.gif > > [created] => > > [modified] => > > ) > > > IN MY VIEW?? > > > I have done it in the past and somehow didn't keep the code snippet > > around. > > > Has it changed in 1.3 now that debug 3 is gone? > > > I do have the echo $this->element('sql_dump'); but it does not have > > the array data. > > > thanks > > > Brad > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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
array dump
Can anyone tell me how to get: Array ( [0] => Array ( [Portfolio] => Array ( [id] => 1 [user_id] => 0 [url] => 29thstreetrep.com [description] => Off-Broadway New York City theater company known for its brutal play selections. [domain_start] => 1999-08-02 [domain_expire] => 2011-08-02 [domain_owner] => David Mogentale [host] => BMCO [category] => theatre [status] => current [img] => portfolio_29thstreetrep.gif [created] => [modified] => ) IN MY VIEW?? I have done it in the past and somehow didn't keep the code snippet around. Has it changed in 1.3 now that debug 3 is gone? I do have the echo $this->element('sql_dump'); but it does not have the array data. thanks Brad 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
Auth / ACL success and now what??
Hey Everyone, I am building a fairly big app and decided to tackle ACL and it is actually working. I have three groups: administrator user artist Here are the permissions: $group->id = 1; $this->Acl->allow($group, 'controllers'); //allow users $group->id = 2; $this->Acl->deny($group, 'controllers'); $this->Acl->allow($group, 'controllers/Users/view'); $this->Acl->allow($group, 'controllers/Users/edit'); $this->Acl->allow($group, 'controllers/UserPreferences/view'); $this->Acl->allow($group, 'controllers/UserPreferences/add'); $this->Acl->allow($group, 'controllers/UserPreferences/edit'); $this->Acl->allow($group, 'controllers/UserPreferences/delete'); //allow artists $group->id = 3; $this->Acl->deny($group, 'controllers'); $this->Acl->allow($group, 'controllers/Users/view'); $this->Acl->allow($group, 'controllers/Users/edit'); $this->Acl->allow($group, 'controllers/UserPreferences/view'); $this->Acl->allow($group, 'controllers/UserPreferences/add'); $this->Acl->allow($group, 'controllers/UserPreferences/edit'); $this->Acl->allow($group, 'controllers/UserPreferences/delete'); $this->Acl->allow($group, 'controllers/ArtistPreferences/view'); $this->Acl->allow($group, 'controllers/ArtistPreferences/add'); $this->Acl->allow($group, 'controllers/ArtistPreferences/edit'); $this->Acl->allow($group, 'controllers/ArtistPreferences/delete'); I thought once this was all set up that a user would only be able to edit their own info and only their own info. For some reason I can (signed in as user) only view that profile associated with the user and once I click "edit user" then I am taken to the edit screen. I can then change the URL to another users ID and their info comes up, ready to be edited and then upon save it updates. I don't know why I can't see other profiles by changing the URL since users have access to view but can edit others with the same access. Also - can someone explain in a few sentences the best way to add admin functions to this? Should I be making separate controller actions. IE. admin-edit, etc.. Will I be using isAuthorized with this to make those declartions. I got this far and am very happy with all the documentation out there but am now kinda stuck as to how to proceed. I have done this with regular PHP but am really trying to learn cakephp and best practices so I can make my app bullet proof. Cake really is amazing and 1.3, hell yeah. Sorry if this is confusing. Been coding and searching for hours today. Thank you so much, Brad 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
HABTM View Question
Having trouble getting all of my tables info in my view. I am trying to get both portfoios and powerdbies table info in there. Right now I can sucessfully get my portfolio info in there like this: portfolios_controller: function currentprojects() { $Portfolio = $this->paginate('Portfolio', array('Portfolio.status' => 'current'), array('contain' => 'User')); $this->set('Portfolio', $Portfolio); } currentprojects.ctp: http://www." target="_blank"> WANT TO INSERT THE LOOP TO GET ALL OF MY IMG FROM MY POWEREDBIES TABLE HERE. NOTHING WORKS - NOT SURE WHAT VARIABLE TO USE?? Here I have the foreach statement for the portfolios info but can't figure out what to do to try and get the HABTM info of poweredbies. I want to have a foreach loop for the related entries. Here is my dump (which seems to be getting the poweredbies info): Array ( [0] => Array ( [Portfolio] => Array ( [id] => 1 [user_id] => 0 [url] => 29thstreetrep.com [description] => Off-Broadway New York City theater company known for its brutal play selections. [domain_start] => 1999-08-02 [domain_expire] => 2011-08-02 [domain_owner] => David Mogentale [host] => BMCO [category] => theatre [status] => current [img] => portfolio_29thstreetrep.gif [created] => [modified] => ) [User] => Array ( [id] => [username] => [password] => [first_name] => [last_name] => [address_1] => [address_2] => [city] => [state] => [zip] => [telephone] => [cellphone] => [email] => [created] => [modified] => ) [Poweredby] => Array ( [0] => Array ( [id] => 1 [img] => portfolioicon_xhtml.gif [PortfoliosPoweredby] => Array ( [id] => 1 [portfolio_id] => 1 [poweredby_id] => 1 ) ) [1] => Array ( [id] => 2 [img] => portfolioicon_css.gif [PortfoliosPoweredby] => Array ( [id] => 2 [portfolio_id] => 1 [poweredby_id] => 2 ) ) [2] => Array ( [id] => 3 [img] => portfolioicon_flash.gif [PortfoliosPoweredby] => Array ( [id] => 3 [portfolio_id] => 1 [poweredby_id] => 3 ) ) [3] => Array ( [id] => 4 [img] => portfolioicon_php.gif [PortfoliosPoweredby] => Array ( [id] => 4 [portfolio_id] => 1 [poweredby_id] => 4 ) ) [4] => Array ( [id] => 5 [img] => portfolioicon_mysql.gif [PortfoliosPoweredby] => Array ( [id] => 5 [portfolio_id] => 1 [poweredby_id] => 5 ) ) ) ) Also - I am using "var $actsAs = array('Containable');" in my models and it is still outputting the user data. Any help would be greatly appreciated. Thank you!! Brad 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@go
Re: Pagination Link Problem
Hey Kryska, Thanks so much for the reply. I made the change to the load and it worked?? I wonder why but am glad that it worked. Still having the pagination issue but this gets me one step closer!! Brad On Jan 22, 1:28 am, kryska wrote: > Hello! > Something similar happened to me...the link "next" worked, but my menu > would disapear! > > I change the way to load my head image. > Instead of: I wrote: > > image('img_cabecera_borrar.jpg'); ?> > Solved! > > I still don´t know why first time image was shown right, but was gone > alfter clicking next button. > > On 22 ene, 04:51, bradmaxs wrote: > > > I am having some major glitch with pagination. > > > Everything is working except for the actual next, previous, number > > LINKS?? > > > The AJAX spinner is working, the pages (amount based on the query) are > > correct and when I run over the NEXT link it shows the correct URL. > > (currentprojects/page:2). > > > The link WILL NOT WORK. If I type it in the browser it takes me there > > but then erases my menu (jquery mbmenu)?? > > > I have prototype and jquery running together and I am using the > > jQuery.noConflict();. > > > I have tried everything - taken out all the JavaScript and tried - > > still no linky!! > > > It must be something silly but I have no idea?? > > > Here is my CONTROLLER business: > > > var $helpers = array('Html', 'Form', 'Javascript', 'Ajax'); > > var $components = array('RequestHandler'); > > var $paginate = array('limit' => 9, 'page' => 1, 'order' => array > > ('Portfolio.id' => 'asc')); > > > function currentprojects() { > > $this->Portfolio->recursive = -1; > > $this->set('Portfolios', $this->paginate(null, array > > ('Portfolio.status' => 'current'))); > > > } > > > The VIEW business: > > > > > > > > width="250" height="200" /> > > > > http://www." > > target="_blank"> > > > > > > > > > > > > > $paginator->options(array('url' => $this->passedArgs)); > > $paginator->options(array('update' => 'pagecontent', 'indicator' => > > 'spinner')); > > echo $paginator->prev('<< previous', null, null, array('class' => > > 'disabled')); > > echo " | "; > > echo $paginator->numbers(); > > echo " | "; > > echo $paginator->next('next >>', null, null, array('class' => > > 'disabled')); > > echo " "; > > echo $paginator->counter(array('format' => 'Page %page% of %pages%', > > true)); > > ?> > > > > image > > ('spinner.gif'); ?> > > > NOTE: I do have the div specified as 'pagecontent' as well. > > > And my ROUTER business: > > > Router::connect('/currentprojects/*', array('controller' => > > 'portfolios', 'action' => 'currentprojects')); > > > Here is the link if anyone is interested and all help is greatly > > appreciated. I hope I have provided enough info. > > > Thanks > > > bradmaxs.com/currentprojects 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
Pagination Link Problem
I am having some major glitch with pagination. Everything is working except for the actual next, previous, number LINKS?? The AJAX spinner is working, the pages (amount based on the query) are correct and when I run over the NEXT link it shows the correct URL. (currentprojects/page:2). The link WILL NOT WORK. If I type it in the browser it takes me there but then erases my menu (jquery mbmenu)?? I have prototype and jquery running together and I am using the jQuery.noConflict();. I have tried everything - taken out all the JavaScript and tried - still no linky!! It must be something silly but I have no idea?? Here is my CONTROLLER business: var $helpers = array('Html', 'Form', 'Javascript', 'Ajax'); var $components = array('RequestHandler'); var $paginate = array('limit' => 9, 'page' => 1, 'order' => array ('Portfolio.id' => 'asc')); function currentprojects() { $this->Portfolio->recursive = -1; $this->set('Portfolios', $this->paginate(null, array ('Portfolio.status' => 'current'))); } The VIEW business: http://www." target="_blank"> options(array('url' => $this->passedArgs)); $paginator->options(array('update' => 'pagecontent', 'indicator' => 'spinner')); echo $paginator->prev('<< previous', null, null, array('class' => 'disabled')); echo " | "; echo $paginator->numbers(); echo " | "; echo $paginator->next('next >>', null, null, array('class' => 'disabled')); echo " "; echo $paginator->counter(array('format' => 'Page %page% of %pages%', true)); ?> image ('spinner.gif'); ?> NOTE: I do have the div specified as 'pagecontent' as well. And my ROUTER business: Router::connect('/currentprojects/*', array('controller' => 'portfolios', 'action' => 'currentprojects')); Here is the link if anyone is interested and all help is greatly appreciated. I hope I have provided enough info. Thanks bradmaxs.com/currentprojects 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: cakephp.org hacked?
I agree with the "Let's just all relax crowd". Of all the things going on in the world, to complain about the developers of Cake putting up a fun and IMO very tasteful theme seems quite ridiculous. The bottom line is Cake never stopped running on my machine because the theme was changed. People didn't stop posting help on the forum, baking apps or developing the newest version for our benefit. If anyone did leave for CI or ZEND, they would have a leg up on others because of the vast knowledge that Cake provides. Rock on CakePHP!! I for one thank you! On Nov 7, 4:03 am, Adrenalin wrote: > There are a lot of boring frameworks with boring websites and luckily > cakephp is not one of them ;) Hooray to cakephp ! Can we have a cool > theme for the New Year too ? :) > > On Thu, Nov 5, 2009 at 3:31 PM, jacmoe wrote: > > > Frameworks are serious?? :) > > Well, I don't know.. > > > Sri Sri Ravi Shankar wrote: > >> Life is nothing to be very serious about. > > > On Nov 3, 11:50 pm, on24 wrote: > >> Hmmm, I just don't like this "funny" theme. My first thought was > >> "CakePHP gone?! Too bad. Let's check Code Igniter then". Serious > >> things like frameworks should not try to be funny. I really can't > >> promote a halloween framework to my colleagues. --~--~-~--~~~---~--~~ 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: the white screen of death
So many times that I get the WSOD it is because I have forgotten to add a ) at the end of a line or there are too many. On Nov 7, 4:53 am, Bruno Bergher wrote: > From previous experience the main cause for this is when > debug_backtrace() is called, in the global debug() declaration > (basics.php:114). > It chokes with undefined variables (in some installations, such MAMP, > this is a pain) and sometimes with very deep associative arrays. > > This message is not too helpful since I have no idea how to solve > this, other than using var_dump() or print_r() in WSOD situations. > > On Nov 6, 8:28 pm, Pedro Nascimento wrote: > > > I got one after copying some config options on files as database.php, > > core.php and app_controller.php using wrong symbols such as ` instead of '. > > It's a stupid mistake, but I have done it once or twice already. :> > > > On Fri, Nov 6, 2009 at 20:08, Tonu Tusk wrote: > > > > OK, I doubt this will be of too much help, but the main causes of WSOD > > > I have encountered have been models not being declared in a > > > controllers $uses var > > > (where a controller is using other than its standard related model) > > > > OR some bad relationships declared in model classes > > > > (I am still a bit unsure of it all, but if i had model A hasOne modelB > > > and modelB belongs to modelA, that really seems to bomb things out for > > > me even though it seems quite intuitive to do so) > > > > Oh yeah, and on one of my other recent posts I was getting random WSOD > > > which turned out to be mod_security installed on my shared host which > > > did not seem to like the combination of either large or a large number > > > of input in post data in combination with being routed through > > > mod_rewrite. > > > > Go figure. > > > > Has anyone else got any "d'oh" obvious and common errors which have > > > led to WSOD to share? > > > > On Nov 6, 9:04 pm, "gimperdan...@gmail.com" > > > wrote: > > > > Yep, > > > > > I already do debug($variable), but when code gets long, it can get > > > > pretty frustrating to test everything. Not to mention that if I get > > > > the white screen than I can't see anything including debug(var). > > > > > My debug option is set to 3. Which is the max, but it doesn't change > > > > anything. > > > > > On Nov 6, 3:14 pm, Céryl wrote: > > > > > > In addition, if the debug level is 2 you can add debug($variable) > > > > > (Either in controller or view) to your code to check that var... So > > > > > you can see if it's an improperly set variable that causes you to > > > > > white-out... > > > > > > On 6 nov, 21:00, jacmoe wrote: > > > > > > > Open app/config/core.php and set the debug level to 1 or 2. :) > > > > > > > On Nov 6, 4:16 pm, "gimperdan...@gmail.com" > > > > > > wrote: > > > > > > > > More often that I would like to I get the "white screen of death", > > > > > > > which tells me something is wrong with my cold. Is there a way to > > > get > > > > > > > printed errors? instead of the white screen? --~--~-~--~~~---~--~~ 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: Cake Hosting - Who is the best?
Yeah - I only use the DV on MediaTemple as well. On Oct 30, 3:20 pm, Jon Bennett wrote: > > Linode FTW. I used to be on SliceHost. Linode is cheaper, for more > > resources, and more discrete upgrades (i.e., on SliceHost if you are > > on the $20 plan, you can double to the $40 and get 512 megs ram; > > Linode starts you at 360 megs ram for $20, and you can go to $30 for > > 540 megs or $40 for 720 megs; plus Linode allows you to install 32 bit > > OS, which will suck a lot less memory than the 64 bit that SliceHost > > requires you to do). > > Heard good things about Linode but not needed new hosting recently so > not had the chance to try. > > j > > -- > jon bennett -www.jben.net- blog.jben.net --~--~-~--~~~---~--~~ 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: Cake Hosting - Who is the best?
I use MediaTemple. www.mediatemple.net. Have for years and the customer support is amazing. On Oct 29, 10:44 pm, TimG wrote: > I know this isn't a cake question but I respect the cake community > more than anybody so I wanted to ask you guys. > > I was using a VPS at hostmysite for $36 a month. It was nice because > it was cheap, linux based, speedy and allowed me to do what I needed > to do like up the php memory limits for resizing images and such. > SHared hosting usually is too darn restrictive... especially is you > want to install a plugin or something. Unfortunately they got rid of > that server option and replaced it with one that is five times the > price. > > So I am once again looking for good hosting that is inexpensive and > doesn't have all the limitations and frustrations that come with > shared hosting. > > Who do you guys use? --~--~-~--~~~---~--~~ 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: $html->link HELP
Thank you both very much. Miles J - your suggestion was it - I can't believe I haven't joined this forum and asked many of my questions earlier. BTW, I am using your Uploader in one of my development sites and it is awesome! TimG - Gonna go read that article at the bakery right now. Thanks for the link! Have a good day Gentlemen. On Oct 27, 4:46 pm, Miles J wrote: > If you are linking to something outside of the plugin, you must do > 'plugin' => null. > > On Oct 27, 4:34 pm, TimG wrote: > > > I found this post > > helpful:http://bakery.cakephp.org/articles/view/taking-advantage-of-the-pages... > > There is a catch all route that you can add last and you can use that > > to help with your URLs. > > > As far as your routes.php file. With that codehttp://site.com/ > > should route tohttp://site.com/pages/display/home > > > Not sure why you're getting the error. Do you have the action/view > > home maybe? So you would want: > > Router::connect('/', array('controller' => 'pages','action' => > > 'home')); which would go tohttp://site.com/pages/home --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
$html->link HELP
Hi All, I am fairly new to cake and just can't seem to get my head wrapped around this. I have made a simple FORUM plugin (placed in plugings folder) and have placed this code is the routes.php file. Router::connect('/forum', array('plugin' => 'forum', 'controller' => 'forum_posts', 'action' => 'index')); ALL GOOD. When I am in my root, I get to the forum. I have a navigation element that I am using in my main app at: cake/app/views/elements/navigation.ctp When I am anywhere in my root my links work great. As soon as I enter my forum plugin, my links suddenly go wacky and lose their routing that I have specified. In root - my home link: echo $html->link(__('HOME', true), array ('controller' => 'pages', 'action' => 'display', 'home')); and in routes.php: Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); alwasy maps to my home page - www.site.com. As soon as I enter the forum, suddenly the link looks like this (www.site.com/forum/pages/display/home) and I get a missing controller error. How can I get rid of the /forum/ part. Do I have to map all the the links with /forum/ infront as well as regular? I hope I have provided enough info and thanks in advance. Brad --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---