歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 24, 2024, 09:05:03 上午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  支援  |  使用與操作  |  [求助]如何summary頁面顯示的文章數量? « 上篇主題 下篇主題 »
頁: 1 [2]
作者 主題: [求助]如何summary頁面顯示的文章數量?  (閱讀 66474 次)
janyo1201
新手見習
*
文章: 14


檢視個人資料
« 回覆文章 #15 於: 十二月 13, 2006, 10:31:33 上午 »

Dear mark ~~
小弟試了貴站所提供的方法,並無法顯示出15篇文章
而且,在/class/summary/dao/summarystats.class.php中的語法,function 宣告的地方也不一樣!!
小弟不曉得該從何處修改!!

以下為小弟的程式碼:

        function getRecentArticles( $maxPosts, $ignoreTopic = "", $ignoreText = "" )
   
        {
            include_once( PLOG_CLASS_PATH . "class/data/timestamp.class.php" );
            include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );

            $t      = new Timestamp();
            $date   = $t->getTimestamp();
         $prefix = $this->getPrefix();

         $query = "SELECT a.id as id, a.id,a.date,
                             a.user_id,a.blog_id, a.status, a.properties,
                             a.num_reads, a.slug
                 FROM {$prefix}articles a,
                      {$prefix}blogs b
                 WHERE a.date >= ".$this->_sevenDaysAgo." AND a.date <= ".$this->_now."
                       AND a.blog_id = b.id
                       AND b.status = ".BLOG_STATUS_ACTIVE."
                       AND a.status = ".POST_STATUS_PUBLISHED;

         $query .= " ORDER BY a.date DESC LIMIT 0, $maxPosts";

            $result = $this->Execute( $query );

            if( !$result )
                return Array();

            $blogs = Array();
            $posts = Array();
            $i     = 0;

            while( ($row = $result->FetchRow()) && ($i < $maxPosts) ) {
                if (!in_array($row["blog_id"], $blogs))
                {
                    $blogs[] = $row["blog_id"];
                    array_push( $posts, $this->articles->_fillArticleInformation($row) );
                    $i++;
                }
            }
           
            $result->Close();           

            return $posts;
        }

已記錄
musa
新手見習
*
文章: 17


檢視個人資料 個人網站
« 回覆文章 #16 於: 一月 22, 2008, 03:45:30 下午 »



修改的檔案:class/dao/summarystats.class.php(註:此路徑為0.32版,1.0路徑為class/summary/dao/summarystats.class.php)
 找到下面的code:(第272-299行)

引用
    function getRecentArticles( $maxPosts )
    { 
        ........
        while( ($row = $result->FetchRow()) && ($i < $maxPosts) ) {
            if (!in_array($row["blog_id"], $blogs))
             {
                   $blogs[] = $row["blog_id"];

                   array_push( $posts, $articles->_fillArticleInformation($row) );
                   $i++;
             }

        }
        return $posts;
    }

   將紅色的部分刪除或註解掉成為下面的模樣:
 
引用
  function getRecentArticles( $maxPosts )
    { 
        ........
        while( ($row = $result->FetchRow()) && ($i < $maxPosts) ) {
             //if (!in_array($row["blog_id"], $blogs))
             //{
             //     $blogs[] = $row["blog_id"];

                   array_push( $posts, $articles->_fillArticleInformation($row) );
             //      $i++;
             //}

        }
        return $posts;
    }


這樣就大功告成了。

這時,回到你的summary.php頁面,Latest Posts部份應該就會不分blog,依時間顯示最近的15篇文章了。

你可以連到本站的summry頁面看看效果。


強烈建議你搭配mark上述的修改一併使用
但,mark上述修改有小錯誤
mark已於另一篇文章中修正,請自行搜尋參考!
我照你說的修改後,是可以show出最新的文章了,可是怎麼會超過15篇,我現在的summary最新文章,可以show到20篇了,要怎麼改成只要15篇就好了。謝謝,我的是lifetype1.2.5 的。
« 最後編輯時間: 一月 22, 2008, 03:47:05 下午 由 musa » 已記錄

lifetype:1.2.7
主機:智邦
頁: 1 [2]
LifeType 中文開發論壇  |  支援  |  使用與操作  |  [求助]如何summary頁面顯示的文章數量? « 上篇主題 下篇主題 »
    前往: