當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Items::current方法代碼示例

本文整理匯總了PHP中Items::current方法的典型用法代碼示例。如果您正苦於以下問題:PHP Items::current方法的具體用法?PHP Items::current怎麽用?PHP Items::current使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Items的用法示例。


在下文中一共展示了Items::current方法的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;
}
開發者ID:boryszielonka,項目名稱:anchor-post-loop,代碼行數:28,代碼來源:post-loop.php

示例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;
}
開發者ID:anotherMe,項目名稱:anchorcms-palms-theme,代碼行數:31,代碼來源:functions.php


注:本文中的Items::current方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。