BlogSimple2

Summary: Simple blog bundle, revision of BlogSimple
Status: Stable
Version: 2007-05-02
Prerequisites: pmwiki-2.1.27, or pmwiki-2.2.0 beta series (for beta version)
Maintainer: JonHaupt
Categories: CMS Blog
Discussion: BlogSimple2-Talk

Questions answered by this recipe

How can I create a blog based on pagelists that doesn't require numbered posts, and where the archive is created automatically?

Answer

Download and install blogsimple2.zipΔ Or blogsimple2beta.zipΔ (see Beta version)

  • BlogSimple2 is based on BlogSimple and still extensively uses pagelists for most functions.

Included are blogsimple2.php, a sample css file for styling the pagelists, and a number of wiki pages to set up the blog in groups Site, BlogArchive, and PostComments.

It differs from BlogSimple in the following ways:

  1. Automatic archive pages (using default text and pagelists)
  2. Blog posts can exist in any group
  3. Post title can be anything, no date necessary

Comment: blogsimple does not require a date either, it is just added to the newpagebox automatically for conveniance. HansB

In this model, posts can appear anywhere, and simply must contain the [[!Blog]] category (or this can be changed). The archive pages are created by changing the default text within the BlogArchive group to automatically show a list of posts that match the title of the page... so BlogArchive/2006-06 would list posts from June 2006.

Installation

unzip into the cookbook/ directory which should create directories

 cookbook/blogsimple2/
         files:blogsimple2.php
               sample-local.css (a sample local.css file for /pub/css)
               README.txt 
               cookbook/blogsimple2/wikilib.d/  pmwiki page store with blog configuration pages

add to config.php:

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

Also, don't forget to install Cookbook:CommentBoxPlus if you haven't already.

Notes

In order to accomplish this recipe as described above, I did the following:

  1. Removed a few variables and added several other ones. The following is a list of variables added using blogsimple2.php:
    • {$Today}, which gives you today's date formatted like 2006-06-07
    • {$TodaySimple}, which gives you today's date formatted like Wednesday 07 June
    • {$BlogDate}, which is the page creation date like 07 June 2006
    • {$BlogDate2}, which is the page creation date like 2006-06-07
      • This one works great for sorting purposes in pagelists by creation date.
    • {$BlogMonth}, which takes a page name beginning with yyyydd and formats it into something readable as in February 2006
      • Used to reformat archive page names into a readable title
    • {$BlogMonth2}, which is another form of the page creation date shown like 2006-06
      • Used for sorting, as the year comes first; also used for the archive pages
    • {$BlogMonth3}, which is another form of the page creation date shown like June 2006
      • For a list of posts but showing only the month and year
    • {$LastModifiedDate}, as in Wed 07 June
    • {$BaseName}, which extracts page names from PostComments group to allow for linkage between the post and its comments page, as described in Cookbook:CommentPageLink
    • {$BlogTimeOfDay}, which prints the time of day of the post, using natural language. These can be set in config.php--look at the php file for more info.
  2. Enabled Cookbook:AllGroupHeader and footer (as Site.SiteHeader and SiteFooter) in order to automatically show the comment box on all footer pages. In order to avoid this showing up on Main and Site groups, you simply have to create a blank page. Or I maybe will just change it so that it won't apply this to those groups.
  3. Created a new default text for the BlogArchive group that shows a pagelist of every post that matches the name of the month, which needs to be in yyyymm form (derived from {$BlogDate2}.
  4. Added Site.BlogListTemplates as a default pagelist page by using the new $FPLTemplatePageFmt, and created several new pagelist templates, as can be found there.
  5. Created pages:
    • BlogArchive/BlogArchive: this page is created on the fly using two pagelists: one that shows all posts in date order, the other showing only the year and months used.

This recipe requires more initial work than Cookbook:BlogSimple for one main reason: since the blog doesn't specifically exist in any one place, you are required to place the pagelists wherever you want them. So you decide where you'd like, for example, the pagelist showing complete blog posts to be placed, and then put the pagelist on that page manually. This also makes BlogSimple2 skin-blind, since I haven't set up any menus. One thing to note is that if you put this recipe in config.php, it's fairly invasive; but if you want it to be confined to a few groups, this is possible as well by using local configuration files.

All you need to do to create a new post is create a page somewhere and add the category link to Blog, as in [[!Blog]]. If you don't want this to show on your posts, you could do %comment%[[!Blog]]%%. If you want to use another category name, you'll need to change the default text for the archives page because it builds the pagelist from link=Category.Blog (and you'll have to change any other pagelists you have as well, obviously--but this is the only one that's hardcoded into blogsimple2.php).

I didn't specifically add any category function to this recipe. I tend to either use the built-in category capabilities of PmWiki or Cookbook:Tags and I think most functions can be accomplished using these two possibilities, but I'm open to suggestions and/or further tweaking.

Advantages

  • Having the archives created on the fly reduces the amount of intervention necessary. Allowing posts to exist in any group and to have any title increases flexibility.

Disadvantages

  • Generally the same disadvantages as BlogSimple. Also, this recipe requires more front-end preparation than BlogSimple as the cost of being more flexible.

Beta version

There is a new version of BlogSimple2 which relies on Page Text Variables instead of categories for the blog to work. Instead of [[!Blog]] in the page, you need to have (:Blog:1:). In addition, in order to execute a pagelist, you need to use $:Blog=1 instead of link=Category.Blog. For example, the following would produce the latest 5 entries in reverse chrono order:

  (:pagelist $:Blog=1 list=blog order=-ctime fmt=#recentblog count=5:)

The new version features some useful changes.

Previously, the page viewed in a pagelist looked quite different from one viewed directly. Now, by using Site.SiteHeader and SiteFooter and Site.BlogMeta, the page template will be the same whether you're viewing the blog using #recentblog pagelist or viewing an individual post. This means that the posts will be styled the same either way, which is a big advantage.

In addition, comments are added on the page itself instead of going to the PostComments page. This seems far less confusing. The comments themselves are still actually stored in the connected PostComments page.

When implementing this new beta version, don't forget to delete former versions of any of the pages in wikilib.d, in particular Site.BlogListTemplates, Site.SiteHeader and Site.SiteFooter, but potentially any of the included pages--otherwise you won't realize the new changes.

  • This recipe was last tested on PmWiki version: 2.2.0.beta31
  • This recipe requires at least PmWiki version: 2.1.27
    • note: the new version of this recipe requires 2.1.27 because it features nested divs and {*$Variable} variables.
    • note: the beta version of this recipe requires the 2.2.0 beta series as it relies on page text variables instead of categories.

Updates

  • 2007-05-02: Bug fixes in beta version. Date archives should work correctly now.
  • 2007-02-23: Added BlogSimple2betaΔ, a version relying on page text variables and making the blog posts appear the same when viewed as a wiki page and within a pagelist.
  • 2007-02-16: Removed commentboxplus from the installation - makes more sense to install that separately. Changed the pagelist templates to feature semantic nested divs. Added a time of day feature. Added a sample stylesheet. Added recipeinfo.
  • 2006-09-19: Included newest commentboxplus2.php, and changed PostComments.GroupFooter so that it uses commentboxchrono instead of a form.
  • 2006-06-21: Fixed the files so that everything pointed to the right folder /blogsimple2 instead of /blogsimple.
  • 2006-06-07: Initial release.

See Also

Contributors

Comments

See discussion at BlogSimple2-Talk

User notes? : 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.