Created
March 11, 2010 02:38
-
-
Save slywalker/328749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/workshop/controllers/posts_controller.php b/workshop/controllers/posts_controller.php | |
index 35c892c..6a2d1e2 100644 | |
--- a/workshop/controllers/posts_controller.php | |
+++ b/workshop/controllers/posts_controller.php | |
@@ -5,7 +5,11 @@ class PostsController extends AppController { | |
var $helpers = array('Html', 'Form'); | |
function index() { | |
- $this->Post->recursive = 0; | |
+ $this->paginate = array( | |
+ 'contain' => array( | |
+ 'User' => array('fields' => array('id', 'username')), | |
+ ), | |
+ ); | |
$this->set('posts', $this->paginate()); | |
} | |
@@ -14,6 +18,10 @@ class PostsController extends AppController { | |
$this->Session->setFlash(__('Invalid Post', true)); | |
$this->redirect(array('action' => 'index')); | |
} | |
+ $this->Post->contain(array( | |
+ 'User' => array('fields' => array('id', 'username')), | |
+ 'Tag', | |
+ )); | |
$this->set('post', $this->Post->read(null, $id)); | |
} | |
@@ -46,6 +54,10 @@ class PostsController extends AppController { | |
} | |
} | |
if (empty($this->data)) { | |
+ $this->Post->contain(array( | |
+ 'User' => array('fields' => array('id', 'username')), | |
+ 'Tag', | |
+ )); | |
$this->data = $this->Post->read(null, $id); | |
} | |
$tags = $this->Post->Tag->find('list'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment