BlogCalendar

Summary: small calendar for blogs showing highlighted links to date-named blog pages
Version: 2017-06-16
Prerequisites: PmWiki 2.2.56 (compatible with PHP 5.5)
Status: stable
Maintainer: HansB
License: GPL2
Discussion: BlogCalendar-Talk
Users: +3 (View / Edit)

Questions answered by this recipe

Is there a calendar like used on blog sites to show links to archived pages?

Description

This recipe adds a new markup which displays as a small calendar for blogs showing highlighted links to date-named blog pages.

Screenshot of blogcal in main page

Screenshot of blogcal in 'clip' RightBar div in Triad skin 'seagreen' color.


Installation

Download blogcal.phpΔ and copy to cookbook folder, download blogcal.cssΔ, create a folder named blogcal in your pub/ folder, and copy file to it. Add to config.php:

include_once("$FarmD/cookbook/blogcal.php");

Usage

Add markup (:blogcal:) to a wiki page to show a small calendar as a view of the current month. By default any pages in the current group with names beginning with ISO date format YYYY-MM-DD like 2008-07-18 or 2014-01-30-MyPostTitle will appear as highlighted links in the calendar.

You can customise the calendar in various ways:

  • Setting defaults in config.php prior of including the script.
  • Customisation of the markup.
  • Customisation of the look by editing the css stylesheet file.

Setting defaults in config.php

$BlogCal['weekstart'] = 1;
First day of the week will be Monday. Default is 0: week starts with Sunday.
$BlogCal['basename'] = 'PrefixName';
prefix to ISO-date pagenames of blog group, like PrefixNameYYYY-MM-DD
$BlogCal['isobasic'] = 1;
ISO-dates used in page names will be basic, without hyphen, format YYYYMMDD, or basenameYYYYMMDD. Default is with hyphen separator: YYYY-MM-DD. This will support YYYYMMDD-BlogPostTitle posts.
$BlogCal['defaultgroup'] = 'MyBlogGroup';
blogcal will look in 'MyBlogGroup' instead of the current group to find matching ISO-date pages.
$BlogCal['pastonly'] = 1;
No link to a future month or post will be shown in the calendar. Default shows future links and months.
$BlogCal['daynames'] = array('Sun','Mon', etc. );
Setting array for abbreviated daynames. By default this is set automatically according your locale settings for different languages (as are the month names displayed).
$BlogCal['multimessage'] = 'posts found:';
A message appended to number if multiple entries are found on a given date
$BlogCal['multimessagefmt'] = 'titlespaced';
The PageList template format to use for the results
$BlogCal['multiresultpage'] = "Blog.Results";
The default wiki page on which to display search results for calendar dates with multiple entries. The default is $BlogCal['basename'].$BlogCal['basename'].

Setting optional parameters in the markup

base=PrefixName
prefix to ISO-date pagenames of blog group, like PrefixNameYYYY-MM-DD
isobasic=1
ISO-dates used in page names will be basic, without hyphen, format YYYYMMDD, or basenameYYYYMMDD. Default is with hyphen separator: YYYY-MM-DD.
group=MyBlogGroup
blogcal will look in 'MyBlogGroup' instead of the current group to find matching ISO-date pages.
pastonly=1
No link to a future month or post will be shown in the calendar caption. Default shows these links.

Setting static calendar views:

month=M
displays month number M of current year, or year specified with year= parameter.
year=YYYY
display current month, or month specified with month= parameter, in year YYYY
tooltip=description or tooltip=Description
display blog page description (given in (:description ..:) markup) as link tooltip. Default is page title, if present, or page name.
tooltip=ptvname
display blog page ptv value as link tooltip; ptvname is name of ptv (without $: prefix). Default is page title, if present, or page name.

Setting additional calendar views: You can use several instances of the (:blogcal:) markup to display several months.

shift=X
for X use number 1, -1, 2, -2 3, -3, etc to show next and previous months; each view shows month shifted by that number from the standard calendar view. Example: 3 months displayed, floated side by side:
%lfloat%(:blogcal shift=-1:)
%lfloat%(:blogcal:)
(:blogcal shift=1:)

Months displayed with shift= parameter do not contain links to next or previous month.

Customising the look

Just change values for the bcal table classes defined in the css style sheet.

Notes

Release Notes

  • 2017-06-16: updated markup definition for PHP 7.2 compatibility.
  • 2014-02-21: updated markup definition for PHP 5.5 compatibility.
  • 2014-01-30: Several tweaks:
    • Supports "-BlogPostTitle" appended to the end of the blog post's page name
    • Supports multiple posts on one day (whether 2014-01-30-1...2014-01-30-2... or 2014-01-30-FirstTitle, 2014-01-30-SecondTitle...)
      • The tooltip changes when there are multiple posts to give the number of posts found and a list of titles or descriptions
      • The link when multiple results are found now brings up a results page (configurable) and search results for all posts on that date using #titlespaced format or a format of your own choosing
    • Now "pastonly" also excludes future post links, so you can schedule posts in the future and links will not be shown.
    • Some changes to the internal code that do not affect the functioning but facilitated the new changes.
    • Note: If you're upgrading, it should not affect past postings. If it does, or misbehaves, please contact XES at http://crisses.org/Main/ContactUs
  • 2008-10-02: Changed a few HTML elements to make output XHTML strict.
  • 2008-08-08: Added tooltip= parameter option.
  • 2008-07-18: Initial release.

Thanks to Feral for FeralSimpleCalendar providing the base for this script
and to Chris Cox for PmCalendar providing parts for it.

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

  • XES - created 2014-01-30 update.

Comments

See discussion at BlogCalendar-Talk

User notes +3: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.