本文整理汇总了PHP中Items::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP Items::valid方法的具体用法?PHP Items::valid怎么用?PHP Items::valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Items
的用法示例。
在下文中一共展示了Items::valid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_list
function post_list()
{
// only run on the first call
if (!Registry::has('rwar_post_archive')) {
// capture original article if one is set
if ($article = Registry::get('article')) {
Registry::set('original_article', $article);
}
}
if (!($posts = Registry::get('rwar_post_archive'))) {
$posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
Registry::set('rwar_post_archive', $posts = new Items($posts));
}
if ($result = $posts->valid()) {
// register single post
Registry::set('article', $posts->current());
// move to next
$posts->next();
} else {
// back to the start
$posts->rewind();
// reset original article
Registry::set('article', Registry::get('original_article'));
// remove items
Registry::set('rwar_post_archive', false);
}
return $result;
}
示例2: tagged_posts
/**
* Returns true while there are still tagged posts in the array.
* This replaces the Anchor posts() method
*
* @return bool
*/
function tagged_posts()
{
$tag = extract_tag();
if ($tag != '') {
if (!($posts = Registry::get('tagged_posts'))) {
$tagged_posts = get_posts_with_tag($tag);
$posts = Post::where_in('id', $tagged_posts)->where('status', '=', 'published')->sort('created', 'desc')->get();
Registry::set('tagged_posts', $posts = new Items($posts));
}
if ($posts instanceof Items) {
if ($result = $posts->valid()) {
// register single post
Registry::set('article', $posts->current());
// move to next
$posts->next();
} else {
$posts->rewind();
}
return $result;
}
} else {
return posts();
}
return false;
}