2010/9/1 Hellbot <g.hellbot@gmail.com>
In controller
$this->set('most_viewed', $this->Post->find('all', array('limit' => 10, 'order' => array('Post.views' => 'DESC')));
In view
$most_view - your top 10
And don't forget add index to "posts.views" column in db2010/9/1 Dave Maharaj <me@davemaharaj.com>
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.I am stumped on how to get top 10 Posts based on the "views" count in the database?
Every time a Post is viewed I auto add 1 to the view count. But to get the top 10?
Any ideas how to do this?
Thanks
Dave
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
No comments:
Post a Comment