This is an old revision of the document!
Table of Contents
previous plugin
Compatible with DokuWiki
No compatibility info given!
Plugin to use the history.back command from javascript within a wiki page. Originally created to use for fullscreen and presentation usage.
The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Installation
In your plugins folder create a folder named “previous”. In this folder you create the file syntax.php with the following content
<?php /** * DokuWiki Plugin previous (Syntax Component) * * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html * @author Theo Klein <tr.klein@tvm.nl> */ // must be run within Dokuwiki if (!defined('DOKU_INC')) die(); if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once DOKU_PLUGIN.'syntax.php'; class syntax_plugin_previous extends DokuWiki_Syntax_Plugin { function getType() { return 'substition'; } function getPType() { return 'block'; } function getSort() { return 304; } function connectTo($mode) { $this->Lexer->addSpecialPattern('{{goback>.*?}}',$mode,'plugin_previous'); } function handle($match, $state, $pos, &$handler){ $match = substr($match, 8, -2); list($url, $alt) = explode('>',$match,2); // set defaults $opts = array( 'alt' => $alt, ); return $opts; } function render($mode, &$R, $data) { if($mode != 'xhtml') return false; if(!$data['url']){ $R->doc .= '<div class="plugin_previous">'; $R->doc .= '<a href="javascript:history.go(-1)" title="'.hsc($data['alt']).'">'; $R->doc .= hsc($data['alt']); $R->doc .= '</a>'; $R->doc .= '</div>'; }else{ $opts = array( 'title' => $data['alt'], 'src' => $data['url'], 'style' => 'width:'.$data['width'].'; height:'.$data['height'], ); if(!$data['border']) $opts['frameborder'] = 0; if(!$data['scroll']) $opts['scrolling'] = 'no'; if($data['align']) $opts['align'] = $data['align']; $params = buildAttributes($opts); $R->doc .= '<div class="plugin_previous">'; $R->doc .= '<a href="javascript:history.go(-1)" title="'.hsc($data['alt']).'">'; $R->doc .= hsc($data['alt']); $R->doc .= '</a>'; $R->doc .= '</div>'; } return true; } } // vim:ts=4:sw=4:et:enc=utf-8:
Optional: Css
If you want an other color or anything; create a style.css file within the Previous map, with for example:
div.plugin_previous a{ color: #007500 !important; }
Syntax and Usage
The use is fairly easy, since this plugin was created for one purpose only: go back!
Syntax examples:
{{goback>TEXT}}
or
{{goback>or multiple words..}}
You can use any text you want, it will display as a ordinary link.
Keep in mind this plugin will only go back one page in your current browser (or tab) history. It does not work on breadcrumbs (which can be a combination of various sessions in multiple windows/tabs).
Questions
Should anyone have questions… here's the place