Recent Topics

1 Aug 04, 2007 02:39    

Chessboard render plugin


Chessboard render is a plugin for B2evolution blogs that converts FEN notation or an alternative 8×8-layout to a chessdiagram using XHTML with 8×8 images.


This plugin is made by vyvy at Originally he made a plugin for B2evo 0.9, but it was soon forgotten because it was not compatible with 1.6. Vyvy made ports for [url=]Drupal[/url] (can't find it anymore on that site) and Michael Arlt for [url=]DokuWiki[/url]. The plugin is based on replacement code in chessboard_render.php, a nice piece of programming skill. I made some minor changes. This is my second attempt getting it to work on B2evo. Now I succeeded. My motivation was the underlying code. It opens possibilities for look alikes like checkers and even card games.


The plugin uses [url=]FEN syntax[/url] to describe a chess position. FEN stands for Forsyth-Edwards Notation. This is an example:

# Byrne - Fisher (1956) Game of the Century

The numbers are empty squares, the letters represent pieces in English (King, Queen, Rook, Bisshop, Night, Pawn). Upper case letters are for the white pieces. Notation starts at a8 (upper left corner). The code in brackets is optional. This tells us to render borders at the Bottom, Top, Right and Left (all four). Comments are made on a line starting #.

This board may also have been described using an easier to understand 8x8 syntax. You use whatever suits you best.

# Byrne - Fisher (1956) Game of the Century

This is what it looks like when rendered:

Byrne - Fisher (1956) Black plays 17. ..., Be6 (x marks the spot), while the queen is hanging on b6. Not only does Fisher win, it is also shown it is the only move that doesn't loose in this position.

By playing with the options you can make subsets of the board. (TR4l) creats a four column board with two borders, Top and Right. The starting piece Top Left is white. We now have the top right corner of the board. If we inject:


We get:

Notice that I added four rows in the code. If I added more rows, the table would have gotten larger but not wider.



Parameters (flags)

T -> Border Top (default: no border)
B -> Border Bottom
L -> Border Left
R -> Border Right
[1..8] -> Number of colums (default = 8)
l -> Starting with a light square (default)
d -> Starting with a dark square

Pieces - use lowercase for black and uppercase for white

P / p -> Pawn
R / r -> Rook
N / n -> Knight
B / b -> Bishop
Q / q -> Queen
K / k -> King
x -> empty square with X
- or [1..8] -> empty square

Lay out

You can make a different set of images. You need to give them the same filename though. If you keep this set in a different folder, you can enable this new set by pointing to the new map (change path) in the edit section of the plugin.
If you need to layout the images, the all have the same class attribute: chessboard. In your css you can call them through:

border: 0;


The code for chessboard_render.php is licenced under GNU [url=]GPL2[/url].


[url=]Version 2.1 beta[/url]: Stable, added image path options. Needs testing for functions and errors. Tested in B2evo 1.8.7, 1.9.3, 1.10.2 & 2.0 a.
Version 2.0 alpha: Working and stable, not completed.


Download the zipfile, open it and place it in the ../blog/plugins/ folder. It should now show in the backoffice (Global settings -> Plugins) Click Install new and choose Chessboard render. Now click the edit button or the link in the name to go to the control panel of the plugin. Here you can change the path setting.


If you have questions or find some unexpected behaviour, post in the Plugins & Extentions section of the B2evolution forum. I will take it on from there.
If for whatever reason I changed some code and forgot to update this reader, this is the [url=]entry in my blog about this plugin[/url]. You can leave a comment there if you wish.

Final remarks

I hope I get at least a few serious downloads and people actually using it and writing in there blogs about chess. If not, that's fine with me too. I enjoyed (re-)writing the plugin and learned some interesting stuff. B2evolution rules.

Form is loading...