blogtng plugin by Gina Häußge, Michael Klier, Andreas Gohr
A next generation blog plugin for DokuWiki
Last updated on 2009-06-07. Provides Syntax, Helper, Action.
Compatible with DokuWiki devel.
Similar to blog, discussion, tag.
The BlogTNG integrates a powerful blogging engine into DokuWiki. It is meant as the successor of the original blog plugin. It contains all components that can be expected from a usual blog like, comments and tags.
WORK IN PROGRESS the BlogTNG plugin and this documentation are not yet finished. Documentation probably needs to be split in several pages later.
Note: on this page “entry” is a synonym of “blog post”.
The plugin is still in development and can only be obtained via a git checkout. To download, go to the
and look for a button “Download Source” near the top of the page. Click this to download a compressed tar file. Unpack the tar file in dokuwiki/lib/plugins and rename the resulting directory to give dokuwiki/lib/plugins/blogtng.
BlogTNG uses the relational database system SQLite to store all metadata. Using a database (as do many other blogging packages, for example WordPress and Movable Type) provides very fast access to individual posts from display pages and indexes. Storing blog post creation dates in a database also provides the necessary infrastructure for importing blog posts from other systems. This is an improvement over the older blog plugin, which used filesystem timestamps to track creation dates.
Unlike with many other blogging packages, you do not need to worry about installing a database system and connecting to it. An SQLite implementation is bundled with PHP 5 and is enabled by default. You already have PHP 5 if you are successfully running a recent version of DokuWiki.
Every blogging system has a slightly different concept of blog. For the old blog plugin a blog consisted of all the DokuWiki pages in a given namespace, with each page being one post in the blog. With BlogTNG a post is again a DokuWiki page, but the organization is different.
One creates a BlogTNG blog by creating a new entry template. Then any time any DokuWiki page is edited, the edit form provides a “Blog” drop-down menu that allows you to select any defined blog (or none, of course), to which you would like to add that page. A page/post can belong to at most one blog.
A BlogTNG blog is thus just a set of pages, each of which can be displayed as a post. The pages can be anywhere within the hierarchy of namespaces. The namespace organization can be used, if you like, to separately categorize blog posts.
Pages which display blog posts are again distinct from blogs. When it comes time to display, the very flexible BlogTNG syntax allows you to merge streams of posts from multiple blogs, choose subsets based on tags, select different formats appropriate for the purpose at hand, and add related material such as comments.
Template files, in lib/plugins/blogtng/tpl, have three main functions:
These templates are specific to the blog-related parts of your DokuWiki installation. They are PHP files, similar in spirit to the main DokuWiki page templates. Arbitrary HTML may be inserted in template files; all DokuWiki functions may be used; and specialized methods are provided to include specific blog-related content items (as in the $entry→tpl_created() example above; see $entry below for details).
A blog typically has several different kinds of displays. For example, the home page typically lists the most recent several blog posts, while following a permalink to one post usually displays a single post with more features (e.g. comments) than are shown on the home page. To a first approximation, BlogTNG manages each of these display types with a different template.
Templates are named after the following scheme: <name>_<type>.php. <name> is for an individual design. <type> is for the type of display managed (e.g. list or single entry). There are five types of templates, described below. For each of these a default template is provided in the software distribution and described briefly here. Only the content produced by the template is described here. For the HTML tags relevant to writing appropriate CSS, it is probably best just to try producing some sample pages and using a browser to view the page source.
An entry template is used to show a single entry. For example, following a permalink to a particular blog post will show a page specified by this template.
The default template provided, default_entry.php, shows
A comments template is used to display a single comment, usually in a list of comments. For example, the default_entry.php template invokes a method $entry→tpl_comments(), which in turn applies the default_comments.php template once for each comment attached to the post.
default_comments.php shows
A list template is used to display a single blog post, usually in a list of posts. For example if you use the list syntax below to specify a home page with the most recent 10 posts, the list template would be applied once for each of the 10 posts.
There are two sample list templates included in the distribution.
The default_list.php template shows
The small_list.php sample template shows
A feed template is used to specify the content included in an RSS feed of the blog. The template is called once for each entry.
The default_feed.php template shows:
When the recentcomments syntax is used to display just a list of comments, it is displayed using a recentcomments template. The template is used once for each comment.
The default_recentcomments.php sample template shows
describe the functions provides here
Outputs the tags of a blog entry.
$target – An existing wiki page which lists blog entries using syntax for listing entries
Other config options
Most functions can be accessed via the <blog *> syntax. Within the <blog></blog> tags configuration options can be specified, one option per line.
This is the most common syntax mode. It simply displays several entries from the wanted blog(s) using a *_list.php template.
Example:
<blog list> blog myblog, someotherblog tpl default cache 0 sortby created limit 6 </blog>
Possible options:
| Option | Default | Description |
|---|---|---|
| blog | default | One or more blog names (comma separated) |
| tpl | default | The *_list.php template to use for displaying each post |
| sortby | created | In what order your posts should be displayed. Can be 'created', 'lastmod', 'title', 'page' or 'random' |
| sortorder | DESC | In what order to sort the entries. Can be 'DESC' or 'ASC' |
| limit | 5 | How many entries to display |
| offset | 0 | Skip some entries from the start |
| tags | Only display entries matching certain tags (comma separated) | |
| cache | 1 | Set to 0 to disable the cache (you usually want this) |
| listwrap | 0 | Set to 1 if your template contains list items that should be wrapped in <ul> tags |
This syntax add a pagination bar to your page. It should be used on the same page as a <blog list> call.
Example:
<blog pagination> blog myblog, someotherblog </blog>
Important: you need to specify the same blog and tag options as in the list call to make sure pagenumbers are calculated correctly.
Possible options:
| Option | Default | Description |
|---|---|---|
| blog | default | One or more blog names (comma separated) |
| tags | Only display entries matching certain tags (comma separated) | |
| cache | 1 | Set to 0 to disable the cache |
Display a list of related blog entries.
Example:
<blog related> blog myblog, someotherblog page myblog:a_post </blog>
To find related posts, this tool compares the tags of all posts in the given blogs with a reference set. When you specify the tag option it uses the given tags from that. When you give a page option it will use the tags assigned to that page. If no page is given, the current one (e.g. the one where this call was placed) is used.
| Option | Default | Description |
|---|---|---|
| blog | default | One or more blog names (comma separated) |
| tags | Use these tags for finding related pages (comma separated) | |
| page | Use this page to get reference tags | |
| cache | 1 | Set to 0 to disable the cache |
Inserts a form to create new blogposts.
Example:
<blog newform>
title add a new page
blog myblog
format blog:%Y-%m-%d:%{title}
</blog>
The form will only be displayed if the currently logged in user has enough permissions to create the resulting blog page.
Possible Options:
| Option | Default | Description |
|---|---|---|
| blog | default | One blog name to assign to the new entry |
| title | A title to display above the form | |
| format | Defines how the new blog entry should be named | |
| select | An optional, comma-separated list of entry titles the user has to select from. |
For the format option you can use any strftime format string and the following placeholders:
| Placeholder | Description |
|---|---|
| %{user} | The login name of the currently logged in user |
| %{title} | The blog title given in the form |
List the most recent comments using one of the *_recentcomments.php templates.
Example:
<blog recentcomments> blog myblog, otherblog tpl sometemplate limit 10 type comment, linkback nolistwrap 1 </blog>
Possible Options:
| Option | Default | Description |
|---|---|---|
| blog | default | One or more blog names of which comments should be shown |
| limit | 5 | Number of comments to be shown |
| tpl | default | The template to display a single comment |
| type | Comma separated list of comment types to be shown, if not set all are shown | |
| nolistwrap | 0 | Set to 1 if your template does not contain list items |
Display a tag cloud for one or more blogs.
Example:
<blog tagcloud> blog myblog,otherblog limit 25 target somebloglisting:page </blog>
Possible Options:
| Option | Default | Description |
|---|---|---|
| blog | default | One or more blog names of which tags should be shown |
| limit | 25 | Number of tags to be shown |
| target | Wiki page which contains the listing syntax |
more syntax modes?
If you've been using the blog plugin (along with the plugins discussion, tag, linkback) you can use the blogtng import script to import your old blogs into the blogtng database.
Just download it, put it into <dokuwiki>/bin and make it executable1). For a quick overview of the script options use --help.
The script has a --dryrun option, use it to verify that the right pages are found and imported. You can import single pages as well as whole namespaces into a blogtng blog. At the moment, you to specify the user for which the blog entries should be imported for. This user needs to be a valid username in your DokuWiki install.
Important: It is recommend to perform the actual import on a separate wiki instance (also backup your old data). The script will delete all meta files used by the old plugins and remove their syntax from the imported pages!
Here are some examples of the script usage.
Import the namespace blog:foo into the blog default:
%> ./blogtngimport.php --user user --ns blogs:foo
Import the namespace blog:foo into the blog myblog:
%> ./blogtngimport.php --user user --ns blogs:foo --blog myblog
Import the namespace blog:foo into the blog myblog explicitly setting author/mail:
%> ./blogtngimport.php --author 'Author Name' --mail 'mail@mail.com' --ns blogs:foo --blog myblog
Import a single page into the blog myblog:
%> ./blogtngimport.php --user user --page blogs:foo:page --blog myblog
Note: If you're unsure about sth. just append --dryrun and watch the output of the script.
| Parameter | Description |
|---|---|
$_REQUEST['btng']['post'] |
|
blog | blog of the blog post |
tags | comma separated list or array of tags for filtering entries |
$_REQUEST['btng']['new'] |
|
title | title of the new blog post |
format | format to use for generated id of new blog post |
$_REQUEST['btng']['pagination'] |
|
start | offset start on paginating blog entries |
$_REQUEST['btng']['query'] |
|
string | query of search request |
filter | filter criteria for search request |
You can link through your blogs feed by adding this feed.php?mode=blogtng&blog=<blogname> to your base URL…
chmod +x blogtngimport.php