It's better when it's simple

User Tools

Site Tools


smblink Plugin

Compatible with DokuWiki


plugin A replacement for DokuWiki's default Windows Share Link feature which supports Firefox

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with firefox, links, samba, share, smb

By enki


A replacement for DokuWiki's default Windows Share Link feature which supports Firefox. This plugin replaces the default action of Windows Share Links (WSL) to better support the Firefox browser. WSLs are still created the same way:


And in Internet Explorer, links will still be the same:


But in Firefox, the link will run a JavaScript onclick which redirects to:


This, in itself, is pretty useless, but with a neat little script and registry fix (discussed here and available for download here) this will now make Firefox launch the smb: link in Internet Explorer, thus dealing with the file as if you were running IE. I know it's a hack, but that's life! ;)

Oh yeah, if anyone can think of a better way to do this, I'd love to hear it! Further, I don't currently have a Linux box to test any of this, but I could pretty easily modify this to work for any smb: links as well (in fact that was my original plan, but I got lazy. ;) )




  1. To install using plugin manager, paste the url into the Download and install field.
  2. If you're using Firefox and Windows, download and install to properly handle the smb: protocol.
  3. See issues below.

Change Log

  • 2009-02-09
    • Using the new samba link handler, as the old one is deprecated.
    • Cleaned up the code, added some fluffy comments.
    • The new handler doesn't show the black command window box.
  • 2007-07-09
    • Added linux support
  • 2007-06-03
    • Initial release


There's an annoying javascript alert box that always pops up. I can't seem to override this using the plugin API, so the only way to fix it is to comment it out of doku's source. The line is in lib/scripts/script.js:


Simply comment the line out:

//                    alert(LANG['nosmblinks']);

Obviously the warning will now not show up even if you don't have the smb url handler installed.

:!: The sole purpose of the checkWindowsShares function is to loop through all the links in the page and add the annoying popup to every link to Windows shares in the page. I suggest commenting the call to the checkWindowsShares() function instead. Same end result but this saves at least 1 function call and 1 loop, every time a page is rendered.




Bering, 2009/12/02 12:43

I was rather hacking together such hack by disabling the JavaScript value of an alert, however this also requires change in core:

--- dokuwiki/lib/scripts/script.js~    2010-04-29 15:42:12.000000000 +0300
+++ dokuwiki/lib/scripts/script.js    2010-04-29 15:43:39.640053591 +0300
@@ -512,7 +512,7 @@
         for(var i=0; i<elems.length; i++){
             var share = elems[i];
-                if(document.all == null) {
+                if(document.all == null && LANG['nosmblinks']) {
--- /dev/null    2008-11-04 20:33:38.146691408 +0200
+++ dokuwiki/lib/plugins/smblink/script.js    2010-04-29 15:45:59.670031225 +0300
@@ -0,0 +1,4 @@
+addInitEvent(function() {
+    // Reset warning as we now handle the links for all OS
+    LANG['nosmblinks'] = '';

Elan Ruusamäe, 2010/04/29 15:48


If you've got any comments or questions, please feel free to add them here. You might consider also emailing me since I might not check back all that often. :)


Linux works fine with just smb://host/path/to/share (at least FF does - not tested in Konqueror but should work). So I hacked this around a bit to have it work in both Windows FF and Linux…

Great work! Integrated it! I would've done this, but I don't currently have access to a linux box :$ Thanks for the contribution! ~Enki

Windows 7

The plugin doesn't work with Windows 7 Prof. german (64bit) and Firefox 3.6.3 (german). The errormessage is “Für die Dateierweiterung ”.js“ gibt es kein Skriptmodul.” which means there is no module for .js-fileextension in wscript.exe in Windows 7 Professional - out of the box.


If you don't want to install the smblink-hack, there is a Firefox Addon which allows to open links to local files: Localllink. With the Addon installed, you can right-click on links to windows shares and chose the option to open these links in a “local context”.

spaces in file path

Will there be support for linking to a file path that includes spaces?

Source Code


 * Plugin SMB: Makes file system links globally accessible, even through Firefox.
 * @license    GPL 2 (
 * @author     Enki <>
// must be run within DokuWiki
if(!defined('DOKU_INC')) die('meh.');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
class syntax_plugin_smblink extends DokuWiki_Syntax_Plugin {
     * return some info
    function getInfo(){
        return array(
            'author' => 'Enki',
            'email'  => '',
            'date'   => '2009-02-09',
            'name'   => 'SMB Plugin',
            'desc'   => 'Makes filesystem links globally accessible, even through firefox.',
            'url'    => '',
    function getType(){ return 'substition'; }
    function getAllowedTypes() { return array(); }
    function getSort(){ return 295; }
    function connectTo($mode) {
        //Add the smblink pattern to the lexer. Pattern will match [[\ASDF]]
     * Handle the match
    function handle($match, $state, $pos, &$handler){
        //Break the link out of [[ ]] and split it into link and description if there is a '|'
        $link = preg_replace(array('/^\[\[/','/\]\]$/u'),'',$match);
        $link = preg_split('/\|/u',$link,2);
        return array($state, $link);
     * Create output
    function render($mode, &$renderer, $data) {
        if ($mode != 'xhtml') return;
        global $conf, $lang;
        list($state, $matchdata) = $data;
        list($url, $name) = $matchdata;
        //If no name is given, use the last bit of the url
        if (strlen($name) == 0) {
            $urlbits = preg_split('/(\\\|\\/)/u',$url);
            $name = $urlbits[count($urlbits)-1];
        //simple setup
        $link['target'] = $conf['target']['windows'];
        $link['pre']    = '';
        $link['suf']   = '';
        $link['style']  = '';
        $link['name'] = $renderer->_getLinkTitle($name, $url, $isImage);
        $link['title'] = $renderer->_xmlEntities($url);
        if ( !$isImage ) {
            $link['class'] = 'windows';
        } else {
            $link['class'] = 'media';
        //Format the link for smb (Linux or Win-Firefox)
        //Just replace all \ with / to get something like smb://host/path/to/file
        $smburl='smb:' . str_replace('\\', '/', $url);
        //If we're using linux, then smb:// protocol works fine.
        if (strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) {
            $url = $smburl;
        } else {
            //If we're not on linux, we might be using IE, so...
            //Replace the \\ with the file:/// protocol and put the \\ back in
            $url = str_replace('\\\\', 'file:///\\\\', $url);
            //Use javascript to change the link in Firefox to the smb url.
            $link['more'] =
                'onclick="if(document.all == null){' .
                    "parent.location='".$smburl."';" .
                '}" ' .
                'onkeypress="if(document.all == null){' .
                    "parent.location='".$smburl."';" .
        $link['url'] = $url;
        //output formatted
        $renderer->doc .= $renderer->_formatLink($link);


Support Drive Letters

Extend the url-handlers to support driver letters. Modify the url_protocol_handler.js of the

Original Code in the function handleUrl(rawUrl)

		  // rescue some non-conformant URL's eg.
		  // smb://server/share
		  if(arg.substr(0,2) != "\\\\")
			arg = "\\\\" + arg

Modified Code in the function handleUrl(rawUrl):

                if ( arg.substr( 1,1 ) == ":" ) {
                  // support drive letters 
                else {

		  // rescue some non-conformant URL's eg.
		  // smb://server/share
		  if(arg.substr(0,2) != "\\\\")
			arg = "\\\\" + arg
Support deeper directory structures

A path like myserver/share/deeper/still is handled badly as it links to myserver/share only under ceratin circumstances. Here is a Bugfix:

In line 79 replace

arg = arg.replace("/", "\\")


arg = arg.replace(/\//g, "\\")

Otherwise //myserver/share/deeper/still will be changed to \\myserver\share/share/deeper/still which the explorer can't open (look at the slashes).

plugin/smblink.txt · Last modified: 2023-10-31 00:07 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki