Integrate DokuWiki to your website

What

  • From your PHP code, get any page from your DokuWiki installation and display it as you wish (within a template, for example).
  • No modifications are required to DokuWiki's source code
  • That's done with a small amount of code

How

DokuWiki works like that: the wiki markup is read by the parser which returns instructions. These instructions are used by the renderer to produce the html code.

How an instruction looks like:

Array
(
    [0] => internallink
    [1] => Array
        (
            [0] => java:spring:hello_world
            [1] => Hello World
        )
 
    [2] => 150
)

Instead of redoing the same process at each user request, DokuWiki has a powerful multi-level caching system. By using it, we can directly get the cached instructions, and use them with a custom renderer to generate our own HTML!

The example

Download it here.

File hierarchy

  • index.php
  • doc.php
  • dokuwiki
  • include
    • DokuWikiRendererXHTML.php

The index page contains links to different wiki pages actually displayed by doc.php, which directly uses data files from the dokuwiki folder (a standard dokuwiki installation). DokuWikiRendererXHTML.php just overrides some methods of DokuWiki's html renderer.

How to make the example work

  • doc.php: update the three variables in the configuration section to match your own configuration.
  • view index.php in your browser (with the same base url that you've put in doc.php). Click on 'DokuWiki standard interface' link. Make a small modification to the two listed wiki pages.
  • go back to index.php and view the examples.

Details

  • DokuWiki use the base url to generate the cache file name, that's why you need to edit the wiki pages on your own machine first.
  • We overrided DokuWiki renderer just to make internal links go to our website pages, not to the corresponding dokuwiki installation pages.
 

Tony
March 14, 2008

Another COOL stuff, something I was looking for a long time. I would suggest two more tutorials when you have free time again ;) A) Customized your Dokuwiki instance to your site theme or template (like in Kohanaphp, where you have green theme all around the site) B) How about Trac integration to your site? Just like in kohanaphp again. I know there are lot of tutorials for above around. But I do not think they will explain things as simple as do.:) Anyway, thank you very much again!
 
write a message
Name


City


Email (won't be displayed)




Antispam: enter the current year (2008)