It's better when it's simple

User Tools

Site Tools


getraw Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" yes
  • 2014-09-29 "Hrun" yes

plugin Creates a url to get raw contents of a wiki, with authorization.

Last updated on

Tagged with data, raw, text

This isn't a standard plug-in. Rather, it's a php script that lets you request the source of a wiki page (what you'd see in the editor) with a url. The request is authorized the same way as a normal dokuwiki page.

This is a useful utility for plug-ins that create urls. For example, a syntax plug-in might produce an iframe for some other script, which wants to do something with the data of the current page. With this plug-in, you can pass in a url that gives you the data you need.

This plug-in allows you to request only what's inside of a code block, so you could have a wiki page that describes a block of code, and that could could easily be imported by another script.

Another use is to store arbitrary text files in your wiki. For example, if you call a wiki page a:b.js and use this script to fetch the page, it will act like a javascript file.


Create the following file in your base DokuWiki directory:

if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
$ID = cleanID(getID());
$onlyCode = $INPUT->str('onlyCode');
$insideTag = $INPUT->str('insideTag');
if (empty($conf['useacl']) || auth_quickaclcheck($ID) >= AUTH_READ) {
	$file = rawWiki($ID);
	if ($onlyCode)
		$file = preg_replace('/[\s\S]*<code>/m', '', preg_replace('/<\/code>[\s\S]*/m', '', $file));
	if ($insideTag)
		$file = preg_replace('/[\s\S]*<' . $insideTag . '[^>]*>/m', '', preg_replace('/<\/' . $insideTag . '>[\s\S]*/m', '', $file));
	print $file;
	print "Unauthorized";


Let's say you have a wiki page called a:b that looks like this:

  ==== My Wiki ====
  And here's some code!
     and things, too!
  </ code>

This url:


will get you all the wiki content. It will not be rendered as HTML.

This url:


will get you just what's inside the code tags:

     and things, too!


Change Log

  • 2015-06-19
    • Removed some unnecessary code from the script. This plugin is no longer dependent on the version of DokuWiki. Tested with DokuWiki Hrun.
  • 2011-08-02
    • Initial release
  • 2011-08-03
    • Switched from direct file access to the getRaw function.


Request for using default plugin structure of DokuWiki

You can implement your feature also by creating an action plugin component in your plugin. See also development of Action Plugins for more details.

An useful event for your case is the ACTION ACT PREPROCESS. You handle your do action here, before DokuWiki checks its default do actions.

(An quite large example, with error handling, is the dw2pdf plugin. See:

If you use the plugin structure, the advantages are:

  • people can update with the Extension Manager
  • people can install via the extension manager, without manually copying a file


: Good idea. Next time I revisit this plugin, I might give it a shot. It should be pretty easy. (2015-07-01)

Usability suggestions

For ease of use, you can set up another rewrite rule in your .htaccess so that a user only needs to add .txt to their URL to get the text format:

RewriteRule ^(.*).txt$ getRaw.php?id=$1 [L]

Also for readability, throw a header('Content-Type: text/plain'); in line 4, and the browser will know to interpret the newlines instead of eating them like HTML. — NReilinghNReilingh

2015-11-29 07:30

plugin/getraw.txt · Last modified: 2015-11-29 07:31 by NReilingh