DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:previous

previous plugin

Compatible with DokuWiki

No compatibility info given!

plugin Plugin to use the history.back command from javascript within a wiki page. Originally created to use for fullscreen and presentation usage.

Last updated on
2010-11-03
Provides
Syntax

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.

Tagged with navigation

By Theo

Installation

In your plugins folder create a folder named “previous”. In this folder you create the file syntax.php with the following content

syntax.php
<?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();
 
 
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, Doku_Handler $handler){
		$match = substr($match, 8, -2);
        list($url, $alt)   = explode('>',$match,2);
 
 
        // set defaults
        $opts = array(
                    'alt'    => $alt,
                );
        return $opts;
    }    
 
 
	function render($mode, Doku_Renderer $R, $data) {
        if($mode != 'xhtml') return false;
 
            $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:

style.css
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 :-)

plugin/previous.txt · Last modified: 2015-05-27 22:36 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