I would like to choose how many views a post must have to be on my “Top Post” widget. To do that, in with my controller i’ve
public function menu() {
return $this->Post->find('all', array(
'limit' => 5,
'order' => array('Post.id' => 'desc'),
'conditions' => array('Post.hits >= 100'
)));
}
and it’s works perfectly.
Now I wand to change my number (100) by a
Configure::read('top_views');
But i don’t know how to do :/ is there someone who can please help me with this?
Change your
menumethod to take a parameter with a default value, update the conditions array.then you can call it and pass in any value you like:
This assumes your
menumethod is in yourPostcontroller, adjust as needed for your own app. Typically this sort of thing should be in the model.