本文整理汇总了PHP中Posts::getRecent方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::getRecent方法的具体用法?PHP Posts::getRecent怎么用?PHP Posts::getRecent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::getRecent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recentAction
public function recentAction()
{
$page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
$limit = 5;
$posts = new Posts();
$this->view->posts = $posts->getRecent($page, $limit);
$total = $posts->getRecent($page, 0, true)->total;
$this->view->paginator = Zend_Paginator::factory($total);
$this->view->paginator->setCurrentPageNumber($page);
$this->view->paginator->setItemCountPerPage($limit);
}
示例2: indexAction
/**
* Site landing page
*/
public function indexAction()
{
$limit = 5;
$page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
$posts = new Posts();
$this->view->posts = $posts->getRecent($page, $limit);
$total = $posts->getRecent($page, 0, true)->total;
$this->view->paginator = Zend_Paginator::factory($total);
$this->view->paginator->setCurrentPageNumber($page);
$this->view->paginator->setItemCountPerPage($limit);
$this->view->keywords = implode('', array('ifphp', 'news aggragator', 'support,' . $this->view->term));
}
示例3: buildPostSearch
/**
* Build the post search index
*
* @param boolean $isCount
* @return boolean
*/
protected function buildPostSearch($isCount = false)
{
$index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->post);
require_once 'Ifphp/models/Posts.php';
require_once 'Ifphp/models/Feeds.php';
require_once 'Ifphp/models/Categories.php';
$posts = new Posts();
$allPosts = $posts->getRecent(1, 0);
if ($isCount) {
echo $allPosts->count() . ' posts would have been added to the post index';
exit;
}
foreach ($allPosts as $post) {
$feed = $post->findParentFeeds();
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('pid', $post->id));
$doc->addField(Zend_Search_Lucene_Field::Text('title', $post->title));
$doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $post->siteUrl));
$doc->addField(Zend_Search_Lucene_Field::Text('link', $post->link));
$doc->addField(Zend_Search_Lucene_Field::Text('feedTitle', $feed->title));
$doc->addField(Zend_Search_Lucene_Field::Text('feedSlug', $feed->slug));
$doc->addField(Zend_Search_Lucene_Field::Text('feedDescription', $feed->description));
$doc->addField(Zend_Search_Lucene_Field::keyword('category', $feed->findParentCategories()->title));
$doc->addField(Zend_Search_Lucene_Field::Text('description', $post->description));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('publishDate', $post->publishDate));
$doc->addField(Zend_Search_Lucene_Field::Keyword('type', 'post'));
$index->addDocument($doc);
}
chown(Zend_Registry::getInstance()->search['post'], 'www-data');
return true;
}