Skip to content

Commit

Permalink
http://book.cakephp.org/view/337/adding-posts
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuz committed Aug 23, 2008
1 parent 9387374 commit 30a27eb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/controllers/posts_controller.php
@@ -1,15 +1,23 @@
<?php
class PostsController extends AppController {

var $name = 'Posts';

function index() {
$this->set('posts', $this->Post->find('all'));
$this->set('posts', $this->Post->find('all'));
}

function view($id = null) {
function view($id) {
$this->Post->id = $id;
$this->set('post', $this->Post->read());

}

function add() {
if (!empty($this->data)) {
if ($this->Post->save($this->data)) {
$this->flash('Your post has been saved.', '/posts');
}
}
}
}
?>

0 comments on commit 30a27eb

Please sign in to comment.