$this->Post->recursive = 0;
$this->set('posts', $this->paginate());
$this->set('mainpost', $this->Post->read(null, $id));
}
HTH,
On Tuesday, April 10, 2012 6:35:54 PM UTC-4, PaulW wrote:
HiI'm on CakePHP 1.3
I have an action in my posts_controller.php that gets a list of latest posts and the data for a particular post if the $id is set...
function mypage($id = null) {
$this->Post->recursive = 0;
$this->set('posts', $this->paginate());
$this->set('mainpost', $this->Post->read(null, $id));
}I then use this to display a column or recent posts and the main post if an $id is supplied.
What I would like to do is set the incoming $id to be the last post entered if a specific $id isn't already set in the URL. ie: run this code if $id is null...
$id = $this->Post->find('first', array('order' => array('Post.id DESC')));
But I'm not sure how to combine these two bits of code together in one function. Assuming that 's the right way to go about what I'm trying to achieve?
PW
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment