Habari - RN Monthly Archives Plugin

General

This plugin show the monthly archives in an unordered list.

Installation

  1. Unzip the file
  2. Put the folder 'archives' to /user/plugins and activate it

Configuration Option

After activated it, click button to setup the plugin.

  • Month displayed as - You can either choose 'Full name', 'Abbreviation' or 'Number' as the display format of the month.
  • Show Monthly Entries Count? - You can choose to show or hide entries count
  • Delimiter to separate day and post title in detail view - Character(s) as the separator between day and post title in detail view.    will be used if leave it blank.

Usage

$theme->monthly_archives( $num_month, $detail_view );
  • $num_month (optional) - Number of recent month(s) to be shown, display all months if this parameter is not provided or provided as 0
  • $detail_view (optional) - Either 'Y' or 'N', ''Y' for showing day with post title with link, 'N' for showing summary only. default is 'Y'

For detail view, a nested unordered list will be shown with the following similar structure.


<ul class="archive-month">
   <li>April 2008 (2)
      <ul class="archive-entry">
         <li>3 Hello World</li>
         <li>1 April Fool</li>
      </ul>
   </li>
   <li>March 2008 (2)
      <ul class="archive-entry">
         <li>3 End Of World</li>
         <li>1 Play Hard</li>
      </ul>
   </li>
</ul>

For summary view, a unordered list will be shown with the following similar structure.


<ul class="archive-month">
   <li>April 2008 (2)</li>
   <li>March 2008 (2)</li>
</ul>

You can use CSS to style the output.

Note

  • Version 0.9 is the first version to support caching. There is a new button added to the plugin page of dashboard to let you to clear the cache. Normally, you don't need to click it since the cache will be expired and regenerated automatically when new post published or some other post status changed affect the output of monthly archives. However, if you found something wrong with your archives output or it doesn't appear, you can click this button to clear the cache and let the new cache generated automatically.
  • Version 1.0 modified to use new FormUI and comply to the new standard of configuration name, please make sure you are using Habari SVN r1948 or later and configure the plugin again.
  • Version 1.1 changed to use theme function instead of theme variable, please note the change of usage.
  • Version 1.3 usage of the plugin is changed in order to support multiple instance calling

Changelog

  • Version 0.5 - Initial release
  • Version 0.6 - Added SQLite support (please use SVN r1350 or later version) and configuration option to display month as 'Full name', 'Abbreviation' or 'Number'
  • Version 0.7 - Support i18n, support detail view (with day and post title),allow show or hide monthly entries count, and allow to display the specific number of most recent months only.
  • Version 0.8 - Added PostgreSQL support
  • Version 0.9 - Added cache support
  • Version 0.9a - Added the clear cache action for the missing scenarios
  • Version 1.0 - Modified to support new FormUI and setup default configuration option during activation
  • Version 1.1 - Changed from using theme variable to theme function for better memory utilization
  • Version 1.2 - Added the support of multi-site installation, thanks bcse for reporting this problem
  • Version 1.3 - Added the support of multiple instance of monthly archives display
  • Version 1.3a - Modified to support both Habari 0.7-alpha (trunk) version and Habari 0.6.x (stable) version

Download

======

簡介

這個 plugin 是用作以一個 unordered list 來顯示 monthly archives。

安裝

  1. 將下載了的 zip file 解壓
  2. 把 'archives' folder 放在 /user/plugins 中,然後啟動 plugin

設定選項

啟動 plugin 後,click 按鈕來設定。

  • Month displayed as - 可以選擇 'Full name'、'Abbreviation' 或 'Number' 為月份的顯示方式
  • Show Monthly Entries Count? - 設定顯示或隱藏每月文章總數
  • Delimiter to separate day and post title in detail view - 適用於 detail view,設定字符來分隔日子和文章連結,如留空的話,   會用作分隔字符

使用方法

$theme->monthly_archives( $num_month, $detail_view );
  • $num_month (不是必須) - 設定顯示最近某個數量的月份,不提供或用 0 則顯示所有月份
  • $detail_view (不是必須) - 如希望顯示詳細日期及文章連結,請提供 'Y',否則提供 'N' 來顯示月份摘要,預設是 'Y'

選用 detail view 的話,類似以下結構的 nested unordered list 會顯示出來。


<ul class="archive-month">
   <li>April 2008 (2)
      <ul class="archive-entry">
         <li>3 Hello World</li>
         <li>1 April Fool</li>
      </ul>
   </li>
   <li>March 2008 (2)
      <ul class="archive-entry">
         <li>3 End Of World</li>
         <li>1 Play Hard</li>
      </ul>
   </li>
</ul>

顯示摘要時,類似以下結構的 unordered list 會顯示出來。


<ul class="archive-month">
   <li>April 2008 (2)</li>
   <li>March 2008 (2)</li>
</ul>

大家可以使用 CSS 來修飾顯示效果。

注意事項

  • 由 Version 0.9 版本開始支援 caching,在 dashboard 的 plugin 頁面中加入了一個新按鈕 。正常來說是不用按這按鈕的,因為當有新文章發表或其他會影響 monthly archives 輸出的 post status 改變,cache 都會自動更新,但如果發現 monthly archives 的輸出有問題,或甚至沒有任何東西顯示出來的話,大家可以按這按鈕來清除 cache。
  • Version 1.0 轉用了新的 FormUI 加上跟隨了新的 configuration name 命名,請使用 Habari SVN r1948 或以後的版本,及重新設定 plugin
  • Version 1.1 由 theme variable 轉用 theme function,請留意使用方法的改變
  • Version 1.3 由於支援多次 monthly archives 顯示,使用方法有所改變

版本資料

  • Version 0.5 - 最初公開版本
  • Version 0.6 - 支援 SQLite (請使用 SVN r1350 或以後版本),新增設定頁選擇月份的顯示方式 - 'Full name'、'Abbreviation' 或者 'Number'
  • Version 0.7 - 支援 i18n,新增 detail view(顯示日子及文章連結),新增選擇顯示月份文章總數及可設定顯示最近某個數量的月份資料
  • Version 0.8 - 支援 PostgreSQL
  • Version 0.9 - 支援 caching
  • Version 0.9a - 補足了一些應該 clear cache 而又遺漏的地方
  • Version 1.0 - 使用了新的 FormUI 和在啟動 plugin 時自動設定 plugin 的預設選項
  • Version 1.1 - 由 theme variable 轉用 theme function 來節省記憶體的使用
  • Version 1.2 - 支援 multi-site 安裝,謝謝 bcse 報告這問題
  • Version 1.3 - 支援多次 monthly archives 顯示
  • Version 1.3a - 支援 Habari 0.7-alpha (trunk) 和 Habari 0.6.x (stable) 版本

下載

56 Responses to “Habari - RN Monthly Archives Plugin”

  1. 6268

    天佑的Archive页面就是通过这个插件来实现的吗?
    Habari里是不是对page的定制是用对指定页面的特定模板来实现的,不是像wordpress里通过后面选择。
    最近想将blog平台转到habari下的想法越来越强烈了。但是模板方面还是挺不适应,以后要多向天佑请教。

  2. 6277

    @iHao:我現在使用中的 archives 頁面就是使用這個 plugin 的,頗簡陋吧? :P

    Habari theme 的彈性我覺得比 WordPress 高,純粹用 file 來決定 template,例如以 Page 就例,正常情況會使用 page.single.php,亦可以用 page.<slug>.php 來把特定 slug 的 page 來另一 template 顯示。

    最近 svn 的更新更加上 <type>.tag.<posttype>.php 這款 template,可以處理某一 tag 的 post 或 page。

  3. 6742

    @天佑:其实我就是因为habari的简洁与高效才有将blog平台转过去的想法,目前我正在将自己wordpress下的一个模板转到habari里面,估计等修改完就转到habari下面吧,必竟我对blog的要求也不是很多,不需要往里面贴照片、视频、源代码什么的。
    但是转换过程中还是遇到些问题一下不知如何解决,比如我的sidebar中需要输出留言最多的用户、留言最多的post,但在现有的system classes里没有找到相应的方法可以调用。
    而像最新post,最新comments,随机post这些我都有找着。
    在sidebar中我还想放置热门tag列表和最近几个月的archive列表,这俩个我看了下你发布的插件,应该可以实现,但我在本地测试时habari时后台一直无法打开插件页面,不知道是不是使用wamp套件环境的原因,所以暂时放下。
    还有相当多的问题也不是太明白,像时区的设置,中文搜索失效,如何使用habari自身的读取rss的功能等问题。
    我对habari还是太不了解,希望天佑有空的话指点一下。

  4. 7108

    @iHao:現在是沒有 API 來輸出留言最多的用、留言最多的 post 的,要自行用 SQL 來做的。

    至於沒法打開 plugins page,有沒有什麼 error message?

    而現時是不支援時區設定的,所有時間皆跟隨 server 設定,這個亦是我同時轉用 VPS 其中一個原因,因為所有東西皆可由我控制。

    中文搜索方面,因未確定怎樣才算最正確的方法在 regular expression 搜尋 unicode 文字,暫時我是用一個 hack 來解決這個問題,複製 system/classes/posts.php 到 /user/classes(所有在 /user/classes 中的 file 會自動 override /system/classes 同名的 file,方便升級時不會 overwrite 自行修改的 file),修改 posts.php 的 144 行

    preg_match_all( '/(?<=")(\\w[^"]*)(?=")|(\\w+)/', $paramset['criteria'], $matches );

    修改為

    preg_match_all( '/(?<=")(\\w[^"]*)(?=")|(\\w+)|(\X+)/u', $paramset['criteria'], $matches );

    而 Habari 的 atom feed URL 是 /atom/1。

  5. 7767

    @天佑
    谢谢天佑的这个中文搜索HACK,现在中文搜索已经ok.
    输出留言最多的用户及留言最多的post我不太清楚该怎么写,对theme.php文件搞不太零清.
    最后有个请求不知道是否合适,想求一份天佑现在用的主题的theme.php文件,参考一下一些功能的实现方法.

  6. 8054

    @iHao:其實 theme.php 的作用和 WP 的 functions.php 差不多,都是放一些 theme 所需要的 functions,方便 theme 的運作和顯示,其中一個常用的做法就是將一些資料 assign 到一個 theme variable 內,在 theme 中只需 echo 出來便可。

    我以輸出留言最多的用戶作為一個例子講解,在 theme.php 中的 add_template_vars() 中,我將以下輸出十個最多留言用戶的 SQL statement 的 result assign 到 $commenters 這個 variable 內。

    SELECT name, email, url, count(*) AS cnt FROM ' . DB::table( 'comments' ) . ' WHERE status = ' . Comment::STATUS_APPROVED . ' AND type = ' . Comment::COMMENT . ' GROUP BY name, email, url ORDER BY cnt DESC LIMIT 10
    

    方法如下。

    $this->template_engine->commenters= DB::get_results( 'SELECT name, email, url, count(*) AS cnt FROM ' . DB::table( 'comments' ) . ' WHERE status = ' . Comment::STATUS_APPROVED . ' AND type = ' . Comment::COMMENT . ' GROUP BY name, email, url ORDER BY cnt DESC LIMIT 10' );
    

    DB::get_results() 會 return 一個 array,用以下的 statement 就可讀取 $commenters 內的內容。

    foreach ( $commenters as $commenter ) 
    {
    	echo $commenter->name;
    	echo $commenter->email;
    	echo $commenter->url;
    }
  7. 18483

    Would it be possible for you to add a feature to only show a few months? Say, I want to show the 5 most recent months only and link to "More".

  8. 18545

    @Randy, add the features to show a few months is so simple. But for the link "More" to show the remaining months. I can't think of a way to implement it except using javascript but I'm a javascript idiot.

    Do you have any other alternative to implement "More" link or give me some information / tutorial web site about similar javascript implementation?

  9. 18553

    Haha, no, I'm not a coder. For the "More" link, I was just thinking of making it link to an Archives page.

  10. 18946

    When trying to save changes for the plugin, v.07, I get the following error:

    "Could not include class file 332w83sshopo4s.php"

    Using the latest svn version of habari. Any ideas?

    Just an idea about the "more" link randy requested. Place the "extra" month in an new container (new ul inside a li or something like that). Add "display:none;" to the stylesheat for the container and add this to the header:

    now a click on "" will slide out the extra month and a nother click will hide them.

    The code is taken from here: http://docs.jquery.com/Effects/slideToggle#speedcallback
    Since habari uses jquery as default it should work nicely. Will try it myself when I get back from home.

  11. 18949

    The same could be done with posts for every month, clicking a month could roll out the posts for that month.

  12. 18997

    is it possible to use the plugin in two ways on the same blog... once to create a recent list of months, the other to do a full archive page?

  13. 19435

    俺楼上的楼上的楼上也遇到了这个问题
    "Could not include class file 332w83sshopo4s.php"

  14. 19513

    @chori, the error of "Could not include class file 332w83sshopo4s.php" is very weird. I'm using FormUI class of Habari to construct the plugin configuration page. Don't know why this error is occurred.

    Have you tried other plugin required to save option? No problem or same error occur?

  15. 19514

    @Randy, I have to think about the best way to implement it. May be included jQuery stuff mentioned by chori.

  16. 19851

    I think I am being extremely dumb here, but I can't get anything to show. I've put on my page, and nothing happens.

    Am I using this wrong? Have I misunderstood where I should be putting the code?

  17. 19911

    @Adam, I've visited your blog and found the plugin working properly. I think you have solved your problem, right?

  18. 19925

    I also get the error: Could not include class file 332w83sshopo4s.php

    I'm using the 4/21 nightly with monthly_archives and flickrrss. The only other plugins I've used so far are the built in ones - flickr silo and the wordpress importer, and both seem to save their settings fine.

  19. 20198

    @chori & mikelietz, the problem is caused by core class file "formui.php", r1594 (http://trac.habariproject.org/habari/changeset/1594) has fixed this problem. Please upgrade to SVN r1594.

  20. 20337

    Great, thanks!

  21. 21429

    天佑你好,我使用這個 plugin ,在最新版本的 Habari ,遇到了 Undefined variable: monthly_archives 的問題(我用的是 SVN 上的 0.8.1 版,似乎比這頁提供的版本還新)。

    順便提醒一下,您的 page_selector 沒有更新為新的寫法喔! :p

  22. 21432

    不知道我上一篇留言有沒有成功,不過我知道解決方法了… 新版 Habari 的呼叫方法改為 $theme->monthly_archives();

  23. 21465

    @bcse:那個版本是 dmondark (Ali. B) 為了 Charcoal theme 而修改出來的版本。

  24. 21623

    你好,我對於您寫的 plugins 有個小建議,我發現 Blogroll 和 Twitter 這兩個 plugin 可以讓使用者在 theme 中修改 plugin 的呈現方式,如果您的 plugins 都改寫為如此方式,應該會更加有彈性!(而且這樣一來, Ali. B 就不需要另外維護他的 branch 了)

  25. 22000

    @bcse:我會參考一下,剛完成 Habari 的 PostgreSQL support,應該會有時間修改其他東西。 ;)

  26. 33664

    您好,我發現如果在同一個安裝中的多個 Site 中使用這個 plugin ,這些 Site 會使用同一個 cache ,所以可能會在 Site 2 的 Archive 頁面看到 Site 1 的 Archive ,這應該是 Habari Cache 系統的問題,請問有辦法解決嗎?

  27. 33796

    @bcse:謝謝報告這問題,因為現時還未決定怎樣在 core 解決 multi-site 安裝的 cache 問題,所以我更新了這個 plugin 來暫時解決這個問題,你下載新版本 plugin 試試吧。 ;)

  28. 42207

    Hi!

    Thanks for that great Plugin - that's exact what i need ;-))

    But i have a problem with it - i hope you can help me to solve it!!

    Take a look here: http://www.mirrortheworld.de/habari/archiv

    I have made a own template-page with the command to show the archives. But habari/the plugin shows me all entries double - how can i fix it?

    Thanks

    Matthias

  29. 42684

    @Matthias, some more information I would like to know.

    1. What database engine are you using? MySQL, SQLite, Postgres?

    2. What version of Habari are you using? 0.5 stable or SVN HEAD?

    3. Are you using the most updated version of this plugin?

  30. 42828

    Hi!

    i use a MySQL Database and Habari 0.6-alpha and i have the latest version of your plugin. I have tried to fix it by myself - but so success :-((

  31. 43025

    Hi Tinyau,

    I'm running the svn version of Habari and your latest version doesn't work anymore. Take a look at my site to see what's going on.

    Any suggestions?

  32. 43939

    @Matthias, your problem is so weird. I have reviewed the code and can't find any reason the output is displayed twice. Unless you have placed the code twice. Would you please paste the code of your template to Pastoid and let me have a look?

  33. 43941

    Yay, fantabulous!

  34. 43970

    Hi Tinyau!

    Look here: http://pastoid.com/81

  35. 44121

    @Matthias, gotcha. No need to use 'echo', remove it your problem would be solved. ;)

  36. 44182

    Thanks Tinyau - now it is all okay!!

  37. 45509

    “支援多次 monthly archives 顯示”,恕我太笨,没能明白。

  38. 45548

    @Brando:之前的版本就算在不同頁面,都只可以顯示一款設定的 archives,但 version 1.3 改用了 parameter,那就可以在同一頁面或者不同頁面顯示不同設定的 archives,例如在 blog home page 顯示 summary archives (沒有 post 的資料),在 archives page 顯示 detail view archives。

  39. 52868

    Hi, thanks for this great plugin, unfortunately I cant get it running on my Habari 0.6a install. Hopefully you can help. Im getting this error:
    Fatal error: Call to a member function format() on a non-object in /home/path/to/habari/user/plugins/archives/archives.plugin.php on line 208
    Line 208 is:
    $day = $post->pubdate->format( 'd' );
    You can see it not running here.
    Any ideas?

  40. 52903

    @Matthew, are you really using 0.6a / SVN HEAD? pubdate has been changed to use HabariDateTime class in SVN head for some time. I'm running this blog on SVN HEAD as well but have no problem at all.

  41. 52910

    That's the version my Habari is claiming I have, but I'll re-download it just in case.

  42. 52985

    I downloaded the latest Habari and it works now :-D cheers

  43. 77876

    Any idea why my Monthly Archives would link to http://dsale.freehostia.com/{$year} and list December as a month I posted in?

  1. 80424 RN Monthly Archives Plugin 1.3a @ 天佑的自由天地
  2. 43930 RN Monthly Archives Plugin 1.3 @ 天佑的自由天地
  3. 33795 RN Monthly Archives Plugin 1.2 @ 天佑的自由天地
  4. 27441 RN Monthly Archives Plugin 1.1 @ 天佑的自由天地
  5. 25212 RN Monthly Archives Plugin 1.0 @ 天佑的自由天地

Leave a Reply