Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 24 lines (19 sloc) 0.405 kb
6e531cf @mariuz http://book.cakephp.org/view/335/create-a-posts-controller
authored
1 <?php
2 class PostsController extends AppController {
3 var $name = 'Posts';
b008477 @mariuz created an index for controller
authored
4
5 function index() {
30a27eb @mariuz http://book.cakephp.org/view/337/adding-posts
authored
6 $this->set('posts', $this->Post->find('all'));
4fa282c @mariuz added view action
authored
7 }
8
30a27eb @mariuz http://book.cakephp.org/view/337/adding-posts
authored
9 function view($id) {
4fa282c @mariuz added view action
authored
10 $this->Post->id = $id;
11 $this->set('post', $this->Post->read());
30a27eb @mariuz http://book.cakephp.org/view/337/adding-posts
authored
12
13 }
14
15 function add() {
16 if (!empty($this->data)) {
17 if ($this->Post->save($this->data)) {
18 $this->flash('Your post has been saved.', '/posts');
19 }
20 }
b008477 @mariuz created an index for controller
authored
21 }
6e531cf @mariuz http://book.cakephp.org/view/335/create-a-posts-controller
authored
22 }
23 ?>
Something went wrong with that request. Please try again.