DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:talkpage

talkpage Plugin

Compatible with DokuWiki

Adora Belle

plugin Generate a link to a talk page for each page in the wiki

Last updated on
2016-02-03
Provides
Syntax
Repository
Source

Similar to discussion

Tagged with discussion, mediawiki

This plugin generates a link to a Talk Page (like used in Wikipedia or the Vector Template). It is intended to be used in a sidebar of templates not having native talk page support.

Installation

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

Change Log

Syntax

Simply add the macro ~~TALKPAGE~~ anywhere in your sidebar page.

Configuration and Settings

The namespace where talk pages are stored can be set in the config manager. It defaults to talk.

Discussion

I would be super handy if this plugin could generate the discussion link in the floating page tools with the TEMPLATE_PAGETOOLS_DISPLAY event. I know it should be fairly easy but I don't know how to do it unfortunately. — LayneeLaynee

France
2015-07-27 02:42

Several Meta Pages

I added some lines to have multiple meta-pages related to one article page. Here it is an additional data page which could provide rawdata to use for example with the include plugin. Maybe some more people are interested?

<?php
/**
 * DokuWiki Plugin talkpage (Syntax Component)
 *
 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
 * @author  Andreas Gohr <andi@splitbrain.org>
 */
 
// 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_talkpage extends DokuWiki_Syntax_Plugin {
    public function getType() {
        return 'substition';
    }
 
    public function getPType() {
        return 'normal';
    }
 
    public function getSort() {
        return 444;
    }
 
 
    public function connectTo($mode) {
        $this->Lexer->addSpecialPattern('~~TALKPAGE~~',$mode,'plugin_talkpage');
    }
 
    public function handle($match, $state, $pos, &$handler){
        $data = array();
 
        return $data;
    }
 
    public function render($mode, &$renderer, $data) {
        global $INFO;
        if($mode != 'xhtml') return false;
 
        $renderer->info['cache'] = false;
 
        $talkns = cleanID($this->getConf('talkns'));
		$datans = cleanID($this->getConf('datans'));
 
        if(substr($INFO['id'],0,strlen($talkns)+1) === "$talkns:"){
            // we're on the talk page
            $goto1 = substr($INFO['id'],strlen($talkns)+1);
			$goto2 = $datans .':'.substr($INFO['id'],strlen($talkns)+1);
            $text1 = 'back';
			$text2 = 'data';
		}elseif(substr($INFO['id'],0,strlen($talkns)+1) === "$datans:"){
            // we're on the data page
			$goto1 = substr($INFO['id'],strlen($datans)+1);
			$goto2 = $talkns .':'.substr($INFO['id'],strlen($datans)+1);
            $text1 = 'back';
			$text2 = 'talk';
        }else{
			// we are on article page
            // we want to the talk or data page
            $goto1 = $talkns .':'.$INFO['id'];
			$goto2 = $datans .':'.$INFO['id'];
			$text1 = 'talk';
			$text2 = 'data';
            //if(page_exists($talkpage)){
            //    $text = 'talk';
            //}else{
            //    $text = 'add';
            //}
        }
 
        $renderer->doc .= '<a href="'.wl($goto1).'" class="talkpage talkpage-'.$text1.'">'.$this->getLang($text1).'</a><br> <a href="'.wl($goto2).'" class="talkpage talkpage-'.$text2.'">'.$this->getLang($text2).'</a>';
 
        return true;
    }
}
 
// vim:ts=4:sw=4:et:

Boris 2016/01/17 20:19

plugin/talkpage.txt · Last modified: 2016-02-03 18:22 by andi