Re: Product / Category Tree Help
Hi, You need to build and implement closure table, look at this excellent presentation http://www.slideshare.net/billkarwin/models-for-hierarchical-data (page 40), I have recently implemented similar to www.farm.ba , where I now have the ability to create unlimited number of levels. Save your full path in the db, and find posts by path exmp for all products path is products for mens : products/mens for mens shoes: products/mens/shoes for model products/mens/shoes/some-model Regards, Nikola -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Product / Category Tree Help
Create the following db tables: table nodes, where you will have a minimum of the following fields: id, title, path, parent_id, lft, rght, type In the field: path, save the full path on which you will find your posts. Field: type, is reserved for storing content types, eg '1 '. categories, '2 '. products,.. table closures, view presentation table posts, where you store the product description, etc table atachments, where you store the product pictures.. Routing like this Router::connect('/:path/*', array('admin'=false,'controller' = 'nodes', 'action' = 'show'),array('pass'=array('path','page'),'page' ='[0-9]+')); Node::show(); public function show() { $path = func_get_args(); //debug($path); $last_arg = end(array_values($path)); if (is_numeric($last_arg)) { $page = $last_arg; //debug($page); array_pop($path); $path = implode(/, $path); $this - request - params['named']['page'] = $last_arg; } else { $path = implode(/, $path); } } Regards, Nikola -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
RE: Product / Category Tree Help
Thanks, I will explore it and see how it turns out. Dave From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of Salines Sent: Saturday, March 30, 2013 11:13 AM To: cake-php@googlegroups.com Subject: Re: Product / Category Tree Help Create the following db tables: table nodes, where you will have a minimum of the following fields: id, title, path, parent_id, lft, rght, type In the field: path, save the full path on which you will find your posts. Field: type, is reserved for storing content types, eg '1 '. categories, '2 '. products,.. table closures, view presentation table posts, where you store the product description, etc table atachments, where you store the product pictures.. Routing like this Router::connect('/:path/*', array('admin'=false,'controller' = 'nodes', 'action' = 'show'),array('pass'=array('path','page'),'page' ='[0-9]+')); Node::show(); public function show() { $path = func_get_args(); //debug($path); $last_arg = end(array_values($path)); if (is_numeric($last_arg)) { $page = $last_arg; //debug($page); array_pop($path); $path = implode(/, $path); $this - request - params['named']['page'] = $last_arg; } else { $path = implode(/, $path); } } Regards, Nikola -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
RE: Product / Category Tree Help
What I ended up doing is adding path field to the table and a pretty simple function to build the path for each category. It needs to be cleaned up some for contain and cache but initial foundation appears to be in place. So this will build out the actual path no matter how deep the tree is. buildPath() was just to build the initial paths for the new field in the db. When a category is created / modified the path will be automatically created on save. Controller: $this-Category-build_path(); Model: public function build_path(){ $categories = $this-find('all'); foreach ($categories as $k = $v){ $path = ''; $nest = $this-getPath($v['Category']['id']); foreach($nest as $kk = $vv){ $path .= $vv['Category']['slug'] . '/'; } $this-id = $v['Category']['id']; $this-saveField('path', $path); } } And for the breadcrumbs: ?php foreach ($path as $k['Category'] = $v):? ?php $this-Html-addCrumb($v['Category']['name'], array('controller' = 'categories', 'action' = 'view', $v['Category']['path']));? ?php endforeach; ? So in the end I get my respective paths such as: 'all/' 'all/men/' 'all/men/shoes/' 'all/men/sweaters/' 'all/men/watches/' 'all/men/jackets/' 'all/men/jeans/' 'all/men/accessories/' 'all/women/' 'all/women/shoes/' 'all/women/accessories/' 'all/women/jackets/' 'all/women/sweaters/' 'all/women/watches/' 'all/women/jeans/' 'all/men/shirts/' 'all/children/' 'all/children/shoes/' 'all/children/jackets/' 'all/children/jeans/' 'all/children/shirts/' 'all/women/shirts/' 'all/men/jackets/leather/' 'all/men/jackets/leather/black/' 'all/men/jackets/leather/brown/' Still open to other ideas if there is something better or suggestions. Thanks, Dave From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of Salines Sent: Saturday, March 30, 2013 11:13 AM To: cake-php@googlegroups.com Subject: Re: Product / Category Tree Help Create the following db tables: table nodes, where you will have a minimum of the following fields: id, title, path, parent_id, lft, rght, type In the field: path, save the full path on which you will find your posts. Field: type, is reserved for storing content types, eg '1 '. categories, '2 '. products,.. table closures, view presentation table posts, where you store the product description, etc table atachments, where you store the product pictures.. Routing like this Router::connect('/:path/*', array('admin'=false,'controller' = 'nodes', 'action' = 'show'),array('pass'=array('path','page'),'page' ='[0-9]+')); Node::show(); public function show() { $path = func_get_args(); //debug($path); $last_arg = end(array_values($path)); if (is_numeric($last_arg)) { $page = $last_arg; //debug($page); array_pop($path); $path = implode(/, $path); $this - request - params['named']['page'] = $last_arg; } else { $path = implode(/, $path); } } Regards, Nikola -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
retrieving data in a view cake 1.3
hi guys,... can anyone help please,... I have a data that I want to bring up to a view with foreach statement,... I can see notifications in debug mode, but I can't see real results... here is my function code: $friends = $this-Friend-find('all', array('conditions' = array('Friend.user_id' = $user['User']['id']))); foreach($friends as $friend) { $conditions = array('Notification.member_id' = $friend['User']['id']); $notifications = $this-Notification-find('all', array('conditions' = $conditions, 'order' = array('Notification.created' = 'DESC'), 'limit' = 12 )); $this-set('notes', $notifications); // debug($notifications); } and here is the view: ?php foreach($notes as $note): ? strong?php echo $html-link($application-cut($note['User']['firstname'] . ' ' . $note['User']['lastname'], 25), '/profile/' . $note['User']['username']) ?/strong ... ,... ,... ,... ?php endforeach ? and Notification Model belongsTo association: var $belongsTo = array( 'User' = array('className' = 'User', 'foreignKey'= 'member_id'), thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Cake Gallery
Hi All, I am trying to use the cake_gallery plugin https://github.com/vitorpc/cake_gallery for cake 1.3 but for some reason the thumbnail is not generated. Seems some issue with photo.php model?? In firebug i get some errors. bWarning/b (2)/a: imagecreatetruecolor() [a href=' http://php.net/function.imagecreatetruecolor'function.imagecreatetruecolor/a]: Invalid image dimensions [bAPP\plugins\cake_gallery\models\photo.php/b, line b104/b] I have GD on my server. same errors on my server as my xampp server. Anyone have any luck with this or can recommend a gallery plugin with upload and thumb creation Thank you Robert -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Cake Gallery
this is how I upload images and create thumbs in any sizes without any plugin,... of course you have to modify to your own needs,... don't forget to create subdirectories in webroot/photos/ original,... thumbs,... etc,... and chmod to 777 function upload in photos_controller: function upload() { $this-authorize(); $user = $this-User-findById($this-user['id']); if(!($user ($user['User']['photos_limit'] == 0 || $user['User']['photos'] $user['User']['photos_limit']))) { exit('You reached your upload limit'); } else { $fileParts = $_FILES['Filedata']['name']; $secret = $this-generateRandomString(20); $name = str_replace(array('.jpg', '.jpeg', '.JPG', '.JPEG', '.png', '.PNG'), '', $fileParts); if($this-Photo-save(array('Photo' = array('name' = $name, 'user_id' = $this-user['id'], 'secret' = $secret, 'hidden' = 0, 'privacy' = array_search($_GET['privacy'], Configure::read('Site.privacy')) { $this-User-query('UPDATE fociki_users' . ' SET photos = photos + 1' . ', last_public_photo = (SELECT created FROM fociki_photos WHERE user_id = ' . $this-user['id'] . ' AND fociki_photos.privacy = ' . array_search('public', Configure::read('Site.privacy')) .' ORDER BY created DESC LIMIT 1)' . ', last_friend_photo = (SELECT created FROM fociki_photos WHERE user_id = ' . $this-user['id'] . ' AND fociki_photos.privacy = ' . array_search('friend', Configure::read('Site.privacy')) .' ORDER BY created DESC LIMIT 1)' . ' WHERE id = ' . $this-user['id']); $original_file = $this-Photo-getOriginalFile($this-Photo-id, $secret, true); $original_file_path = $original_file-pwd(); $tempFile = $_FILES['Filedata']['tmp_name']; move_uploaded_file($tempFile, $original_file_path); exec('/usr/bin/convert -geometry 400x350 ' . $original_file_path . ' ' . $this-Photo-getMediumFile($this-Photo-id, $secret)-pwd() .' /dev/null 21 '); exec('/usr/bin/convert -geometry 145x145 ' . $original_file_path . ' ' . $this-Photo-getSmallFile($this-Photo-id, $secret)-pwd() .' /dev/null 21 '); exec('/usr/bin/convert -thumbnail x150 -resize 150x -resize 50% -gravity center -crop 75x75+0+0 +repage ' . $original_file_path . ' ' . $this-Photo-getSquareFile($this-Photo-id, $secret)-pwd() .' /dev/null 21 '); exec('/usr/bin/convert -thumbnail x96 -resize 96x -resize 50% -gravity center -crop 48x48+0+0 +repage ' . $original_file_path . ' ' . $this-Photo-getBuddyFile($this-Photo-id, $secret)-pwd() .' /dev/null 21 '); exec('/usr/bin/convert -geometry 500x450 ' . $original_file_path . ' ' . $this-Photo-getLargeFile($this-Photo-id, $secret)-pwd() .' /dev/null 21 '); } echo 'OK'; die(); } } and here is the Model photo.php ?php class Photo extends AppModel { var $name = 'Photo'; var $validate = array( 'user_id' = array( 'rule' = 'notEmpty' ), 'name' = array( 'rule' = 'notEmpty' ), ); var $belongsTo = 'User'; var $hasMany = array( 'PhotoTag' = array('order' = array('tag' = 'ASC')), 'PhotoNote' = array('order' = array('created' = 'ASC')), ); function getOriginalFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'original' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getLargeFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'large' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getMediumFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'medium' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getSmallFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'small' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getThumbFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'thumb' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getSquareFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'square' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getBannerFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'banner' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function getBuddyFile($id, $secret, $create = null, $chmod = null) { return new File(WWW_ROOT . 'photos' . DS . 'buddy' . DS . $id . '-' . $secret . '.jpg', $create, $chmod); } function beforeDelete() { $this-loadModels('PhotoComment', 'PhotoTag', 'PhotoFavorite', 'PhotoLike', 'PhotoDislike', 'Notification'); $photo = $this-findById($this-id());
Re: New to CakePHP
look into /app/config/bootstrap.php file you should have settings something like: Configure::write('Site.contact_email', 'whatever@your_site.com'); Configure::write('Site.contact_email_subject', 'some subject'); On Wednesday, March 27, 2013 10:32:48 AM UTC-7, Ellie Quick wrote: Help, Im a fairly experienced php coder however Ive been given access to a site (as the author is no longer contactable) written using CakePHP and Im totally and utterly lost as to how to make the fairly urgently required fixes. Theres a contact form on one of the pages which doesnt work, no error messages to say whats wrong, Its meant to send an email to the site owner but nothing is ever received. Now this could be as simple as the wrong email address being used through to there simply being no back end code for sending the mail. ive found a file called contacts_controller.php which contains an email function which is clearly designed to send the relevant emails however the bit thats losing me is: $email_to = Configure::read('Site.contact_email'); $email_subject = Configure::read('Site.contact_email_subject'); $email_from = Configure::read('Site.contact_email_from'); I cant find anywhere, either in the site server files or the relevant database anything that appears to hold these variables. Am I being dim? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.