This page explores the use of DokuWiki as a new breed of wiki-based CMS.
DokuWiki gives the site developer almost complete control over how the site looks. This is something rarely seen in other wikis. This makes DokuWiki suitable for use as a CMS in sites that don't appear to be wikis at all. Wikis make it very easy to create web pages and link them together, so why not run a whole site as a wiki, even if the site isn't open to the public for editing? One very cool benefit of using DokuWiki as a CMS is the RSS feed, which makes it possible for users to subscribe to site changes.
On this page we explain how to use DokuWiki as a wiki-based CMS and provide a tutorial for establishing a basic wiki-CMS site. We also explore how we can make DokuWiki even more suitable for this purpose. Instead of trying to find a way to make DokuWiki do what other CMS's do, let's create a new class of CMS that makes sense for wikis in general and that conforms to existing DokuWiki design philosophy in particular.
It's important that any newness be implemented as tweaks or extensions to DokuWiki and not as a distinct code base. The solution should fit DokuWiki naturally. Ideally, our ideas would also propel the standard anyone-can-edit use of DokuWiki into new and helpful places.
See Wiki-CMS Sites for example sites that use DokuWiki as a wiki-CMS.
In order to ensure that this page remains useful and doesn't get too cluttered with discussion, please adhere to the following editorial guidelines:
Of course, we're always open to changing these guidelines, but let's be sure to discuss those changes first. Thanks for your understanding.
Out of fear that the letters CMS might mean wildly different things to different people, let's constrain our definition as follows:
So a wiki-CMS is a generalization of a regular wiki server. Normally a wiki-CMS would probably be maintained by a restricted group of people, so that the general public doesn't even see edit buttons on the page. But perhaps every feature we imagine for wiki-CMS might also be valuable to wikis that are maintained by the general public. This way our contributions could push the envelope of wiki technology.
DokuWiki is pretty close to being what we want already, but it comes up short in a few regards:
Here is an overview and discussion of some of the ways we might address the outstanding issues.
After installing DokuWiki according to the DokuWiki installation instructions, follow these steps to establish a basic wiki-CMS site. When you are done, you'll have a DokuWiki site with the following properties:
You will probably want to further customize the page layout after finishing the installation.
Rename the file conf/local.php.dist to conf/local.php and initialize it as follows:
<?php $conf['title'] = 'Site Name'; //what to show in the title $conf['start'] = 'intro'; //name of default page $conf['template'] = 'wikicms'; //name of your custom lib/tpl/ template directory $conf['useacl'] = 1; //Use Access Control Lists to restrict access $conf['superuser'] = '@admin'; //Create a group of superusers called admin $conf['openregister'] = 0; //Registration not open to the public $conf['useheading'] = 1; //Use the first heading in a page as its name $conf['toptoclevel'] = 2; //Drop page title from TOC $conf['rss_linkto'] = 'current'; //Have RSS feed link to current page, not deltas page $conf['userewrite'] = 1; //this makes nice URLs: 0: off 1: .htaccess 2: internal $conf['useslash'] = 1; //use slash instead of colon? only when rewrite is on //$conf['sepchar'] = '-'; //Use '-' or '.' instead of '_' in page IDs ?>
Review each of the configuration variables and change as appropriate. If you want to hide wikiness from your end users, you'll probably want to use slashes instead of namespace colons; besides, the '#' URL feature to jump to a heading on a page doesn't work in some browsers when using colons. If you want to use a dash instead of an underscore in page IDs, remove the '//' from the front of the 'sepchar' line.
If you opted to have $conf['userewrite'] = 1, you'll need to modify the file .htaccess by removing the ' # ' from the beginning of each line that begins with ' #Rewrite... '.
Rename the file conf/acl.auth.php.dist to conf/acl.auth.php and initialize it as follows. This gives anonymous users read-only access to the site and a group called 'admin' full privileges to the site.
# acl.auth.php # <?php exit()?> # Don't modify the lines above # # Access Control # # none 0 # read 1 # edit 2 # create 4 # upload 8 * @ALL 1 * @admin 16
Rename the file conf/users.auth.php.dist to conf/users.auth.php and add one line to the end of the file for each user who has write access to the site. Each line has the form:
user:MD5password:Real Name:email:admin
Replace the terms shown above as follows:
acl.auth.php.
Copy the entire contents of directory lib/tpl/default/ over to a new directory called lib/tpl/wikicms/ (or to whatever name you gave the directory in $conf['template']).
Replace lib/tpl/wikicms/main.php with the following file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php /** * Sample DokuWiki CMS Template * * This is the template you need to change for the overall look * of your DokuWiki-based CMS site. * * You should leave the doctype at the very top - It should * always be the very first line of a document. * * Modification History: * * 2005/09/28 - Created by derivation from lib/tpl/default/main.php, * authored by Andi Gohr. (Joe Lapp <www.spiderjoe.com>) */ ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang']?>" lang="<?php echo $conf['lang']?>" dir="<?php echo $lang['direction']?>"> <head> <title><?php tpl_pagetitle()?> [<?php echo hsc($conf['title'])?>]</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php tpl_metaheaders()?> <?php $isWritable = ($_SERVER['REMOTE_USER'] && $INFO['writable']); ?> <link rel="shortcut icon" href="<?php echo DOKU_BASE?>lib/images/favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL?>layout.css" /> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL?>design.css" /> <?php if($lang['direction'] == 'rtl') {?> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL?>rtl.css" /> <?php } ?> <link rel="stylesheet" media="print" type="text/css" href="<?php echo DOKU_TPL?>print.css" /> <!--[if gte IE 5]> <style type="text/css"> /* that IE 5+ conditional comment makes this only visible in IE 5+ */ /* IE bugfix for transparent PNGs */ //DISABLED img { behavior: url("<?php echo DOKU_BASE?>lib/scripts/pngbehavior.htc"); } </style> <![endif]--> <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?> </head> <body> <?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?> <div class="dokuwiki"> <div class="stylehead"> <div class="fix_IE6"> <table width="100%" border="0" cellpadding="0" cellspacing="0" > <tr> <td width="2%"> </td> <td class="sitename"><?php tpl_link(wl(),$conf['title'],'name="top" accesskey="h" title="[ALT+H]"')?></td> <td class="toolbar"><?php tpl_searchform()?></td> <td width="2%"> </td> </tr> </table> </div> <?php /*old includehook*/ @include(dirname(__FILE__).'/header.html')?> <div class="bar" id="bar_top"> <?php if($isWritable) { ?> <div class="fix_IE6"> <table width="100%" border="0" cellpadding="0" cellspacing="0" > <tr> <td align="left" id="bar_topleft"> <?php tpl_button('edit')?> <?php tpl_button('history')?> </td> <td align="right" id="bar_topright"> <?php tpl_button('recent')?> </td> </tr> </table> </div> <?php } ?> </div> </div> <?php flush()?> <?php /*old includehook*/ @include(dirname(__FILE__).'/pageheader.html')?> <div class="page_body"> <div class="fix_IE6"> <table width="100%" border="0" cellpadding="0" cellspacing="0" > <tr> <td width="175" class="sidebar">SIDEBAR</td> <td> <div class="page"> <?php html_msgarea()?> <!-- wikipage start --> <?php tpl_content()?> <!-- wikipage stop --> <div class="clearer"> </div> <?php flush()?> <div class="meta"> <?php tpl_userinfo()?> <?php if($isWritable) echo ' · '; ?> <?php tpl_pageinfo()?> </div> </div> </td> </tr> </table> </div> </div> <?php /*old includehook*/ @include(dirname(__FILE__).'/pagefooter.html')?> <div class="stylefoot"> <div class="bar" id="bar_bottom"> <?php if($isWritable) { ?> <div class="fix_IE6"> <table width="100%" border="0" cellpadding="0" cellspacing="0" > <tr> <td align="left" id="bar_bottomleft"> <?php tpl_button('edit')?> <?php tpl_button('history')?> </td> <td align="right" id="bar_bottomright"> <?php tpl_button('subscription')?> <?php tpl_button('admin')?> <?php tpl_button('login')?> <?php tpl_button('index')?> <?php tpl_button('top')?> </td> </tr> </table> </div> <?php } ?> </div> </div> </div> <?php /*old includehook*/ @include(dirname(__FILE__).'/footer.html')?> <?php tpl_indexerWebBug()?> </body> </html>
Note that I used tables for horizontal layout because I haven't found a good cross-browser way to do this with div's. Spider Joe
I found it is useful to let edit button invisible for unauthorized users .
<?php if( is_array( $INFO['userinfo'] ) ) { ?> <?php tpl_actionlink('edit')?> <?php tpl_actionlink('history')?> <?php } ?>
Append the following lines to the end of the file lib/tpl/wikicms/layout.css:
/* --------------- Wiki-CMS Layout ----------------- */
.fix_IE6 { /* IE 6 box model is broken */
width: 100%;
}
.sitename {
padding:.5em 0;
color:#DEE7EC;
font-size:220%;
font-weight:bolder;
vertical-align:middle;
}
.toolbar {
padding-top: 1em;
text-align:right;
vertical-align:top;
}
.bar {
height:auto;
padding:5px 2px;
}
.page_body {
padding:4px 0;
}
.sidebar {
padding:10px 6px;
vertical-align:top;
border-right: 1px solid #8cacbb;
}
.meta {
text-align:center;
}
When the user enters a URL for a DokuWiki page that doesn't exist, the English language files produce the following message:
Other languages likely produce a similar message. Anonymous users will see this message, but it doesn't make sense for them. They don't otherwise know that the site is wiki-based, and besides, they generally aren't permitted to create or edit pages.
If you want to change this message, edit the language file named newpage.txt in the appropriate inc/lang/ language directory; this file contains the message. For example, the English language file is inc/lang/en/newpage.txt.
DokuWiki does not currently provide a way for you to change the format of the page information line that appears at the bottom of each page. This line is given by the function tpl_pageinfo() in the main.php template file. The function currently outputs the filename followed by a bullet followed by a date in a particular format, followed by the username of the last user to change the file.
The right way to address this is to either create one or more new functions to do the job or to extend tpl_pageinfo() to make it more flexible. Both approaches require more thought than the tutorial author feels like doing right now, so you're going to get an ugly hack solution.
This ugly hack solution eliminates the filename and the name of the last user to modify the file, and it formats the date and time in English in a standard U.S. way of showing the date/time. To apply the hack, open the file inc/template.php in a text editor and locate the following lines, which are found within the tpl_pageinfo() function:
$date = date($conf['dformat'],$INFO['lastmod']); // print it if($INFO['exists']){ print $fn;
Insert the following lines after the if() statement:
$datetime = strtotime($date); print 'Last modified on '.date('n/j/Y', $datetime).' at '.date('H:i', $datetime); return;
When you are done you should have the following sequence of lines:
$date = date($conf['dformat'],$INFO['lastmod']); // print it if($INFO['exists']){ $datetime = strtotime($date); print 'Last modified on '.date('n/j/Y', $datetime).' at '.date('H:i', $datetime); return; print $fn;
To provide the date and time in a different format, you'll need to use a formatting string recognized by PHP's date function. You might also want to put your time zone acronym after the time, if you care for the reader to know. To be safe, you should enter the letters each preceded by a backslash, as in “\C\S\T” for the CST time zone.
You should be ready to go at this point, unless something was unwittingly left out of the tutorial. If you include images on the site and have those images link to an image details page, you'll probably want to make the layout of that page consistent with the layout given for the document pages. In any case, you may want to taylor the layout to your own tastes, once you've got the site working.
One particularly interesting trick is to maintain the sidebar as a DokuWiki page, so that you can update it via the web. To do this, first include HTML in the sidebar that should never change, and then insert the following line at the point where the HTML can change:
<?php include(DOKU_INC.$conf['savedir'].'/pages/sidebar.txt') ?>
Please feel free to embellish on this tutorial with other helpful suggestions. Also let us know if something important got left out or if something is just plain wrong.
Below is a list of wiki-CMS sites that use DokuWiki. Please feel free to add your site, or even just to mention a site in progress if you don't want to post a link yet. Let's restrict ourselves to sites that at least in part use DokuWiki in a non-standard, wiki-CMS-like way. By listing your sites and your works-in-progress, we can learn from each other and we can help ourselves and others to assess the demand for using DokuWiki as a wiki-CMS.
This section is for any sort of discussion that isn't simply editorial commentary on language or content. Please post your comments here if you think they may compel further conversation. Please see the Editorial Guidelines for more guidelines on editing this page.
(An initial discussion between Christopher Smith and Spider Joe was removed, as the page has been updated to reflect the concerns and we didn't want the clutter around.)
I just added the most important bit of information about namespace templates.
— Esther Brunner 2005-09-26 12:02
Thank you! I threw the link into the text. Spider Joe
Another couple of quick comments. Great tutorial. In fact the first few steps should be a tutorial for installing and configuring any Dokuwiki installation. The tutorial is quite long compared to the rest of the page content, it could be worth moving it off-page, what do you think?
With regard to a some things in the tutorial:
* Rather than rewrite the dokuwiki functions tpl_pageinfo and tpl_userinfo, you are better off copying them into your template (either main.php or another file included from main.php) and changing their names. That way you don't need to redo the change when ever you upgrade dokuwiki to a new release.
»> — Christopher Smith 2005-09-29 12:16
Great ideas! I'll move the tutorial to a new page and embed the tpl_pageinfo() code (soon). We can also suggest including 'htmlok' and 'phpok', if it makes sense for the write-access users allowed.
I forgot about using one of the sidebar templates, but I think my sidebar template is cool too. Besides, I'd probably have to rework either of those templates to get the buttons in the right spots. Maybe others can contribute other templates?
Take a look at the sidebar template. Its essentially the default template with a couple of minor changes. The essence of the sidebar is “tpl_sidebar()”. That function works out which page to include and displays it. If you includetplfn_sidebar.phpyou can then placetpl_sidebar()anywhere you like in your template to display the appropriate sidebar page. The rest of the template is concerned with breaking the standard template into two column layout, including some specific styles and allowing the sidebar to appear in different locations. You don't need any of that. Simply replace, yourinclude(”…sidebar.txt”);withtpl_sidebar()and ensure you have set the name of the sidebar page to the correct name (it defaults tosidebarso you should be ok) and you are good to go. If you did want to apply the same changes you applied to the default template to the sidebar template you would end up with giving potential users a choice of four locations for their sidebar. — Christopher Smith 2005-09-29 17:53
On the IE6 box model, it is indeed broken, as I've been fighting it for a months now on various projects. The recommended fix that works is to do what I just did. It doesn't always show itself, but embedding tables will often do it. I didn't confirm that these tables cause the problem; I just do it and so always avoid the problem. (FYI, I check my sites on about 7 browsers, and typically they're identical on 6 and broken on IE6, and this box model fix often brings IE6 in line.)
Floating the elements did not work as I expected. That was my first attempt. DokuWiki's template hardcodes the height of the button bar, and I couldn't do that. After fighting it for a while, I reverted to my standard policy of using tables for horizontal placement. Saves me quite a bit of frustration. Spider Joe
While the template and sidebar functionality greatly improve Dokuwiki's chances of being used as a CMS, it still lacks IMHO in integrating other webbased applications. Personally I would love to see it possible to embed something like Gallery2 into Dokuwiki. But after days of reading and trying I still don't see a way of accomplishing this. – Styno 2005-10-17 12:26