DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:backlinks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:backlinks [2015-06-09 04:57] 115.93.88.196plugin:backlinks [2024-01-20 00:46] (current) – [FAQ] 81.220.179.19
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Show a list of all the backlinks to the current page +description: Lists all pages that link back to a given page using the first headline as link title 
-author     : Jonathan Arkell +author     : Mark C. Prins 
-email      : jonnay@jonnay.net+email      : mprins@users.sf.net
 type       : syntax type       : syntax
-lastupdate : 2005-10-24 +lastupdate : 2023-06-27 
-compatible :  +compatible : Hogfather, Igor, Jack Jackrum 
-depends    : +depends    :  
-conflicts  :  +conflicts backlinks-old 
-similar    : backlinks2 +similar    :  
-tags       : listing, links, include+tags       : listing, links, meta, include, backlinks 
 +downloadurl: https://github.com/mprins/dokuwiki-plugin-backlinks/archive/master.zip 
 +bugtracker : https://github.com/mprins/dokuwiki-plugin-backlinks/issues 
 +sourcerepo : https://github.com/mprins/dokuwiki-plugin-backlinks 
 +donationurl: https://github.com/sponsors/mprins 
 ---- ----
 +===== Installation =====
 +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
-===== Description =====+**Note** if you came here looking for the old, unmaintained and unspported plugin it is now available at [[plugin:backlinks-old|Backlinks-old Plugin]]
  
-This is a very simple plugin to display the backlinks of the given page. You invoke it like this:+===== Configuration ===== 
 +The plugin uses the built-in [[doku>dokuwiki|DokuWiki]] functions to generate the backlinks list. You can use the config-variable [[config:hidepages|hidepages]] config option to suppress pages from being listed.
  
-  {{backlinks}}+The plugin uses the wiki index, if you have to use nocache your index is out of date. 
 +===== Syntax ===== 
 +The syntax is as follows:
  
-This will be replaced with an alphabetized list of pages that link to the current page.  +<code> 
 +{{backlinks>wiki:page}} 
 +</code>
  
-===== Plugin =====+You can list the backlinks to the current page by using:
  
-To install, put the following PHP file in ''/lib/plugins/backlinks/syntax.php'' Or download from (or point your plugin manager) here: [[http://wiki.jonnay.net/_media/bunny/backlinks.tar?cache=nocache]] +<code> 
-> As of Nov 1, 2009, the link above is reported as **Unauthorized(([[http://irc.dokuwiki.org/index.php?d=2009-11-01|IRC log]]))**. I'm temporarily uploading a mirror of version 2008-03-21, until I can contact the author. Check {{https://informatica.temuco.udelmar.cl/~lmachuca/files/dokuwiki/plugin-backlinks-20080321.zip|here with the Plugin Manager}}. --  --- //[[luis.machuca@gulix.cl|ryan.chappelle]] 2009/11/01 04:49// +{{backlinks>.}} 
->> That is **NOT** a mirror version. Jonathan Arkell is the author of the [[:plugins|listed]] backlinks plugin. The above "mirror" is the [[plugin:backlinks2|backlinks2]] plugin by Michael Klier which you should get from the official link (and it seems to be slightly outdated). --- //Saxywolf 2009/11/03//+</code>
  
-<code php> +You can include pages from and below certain namespace only using:
-<?php +
-/** +
- * Backlinks: Show list of backlinks for the given pagename +
- * Usage: +
- * {{backlinks>page}} to display the backlinks page in the current namespace +
- * {{backlinks>:page}} for "page" in top namespace +
- * {{backlinks>namespace:page}} for "page" in namespace "namespace" +
- * {{backlinks>.namespace:page}} for "page" in subnamespace "namespace" +
- * +
- */ +
-  +
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +
-require_once(DOKU_PLUGIN.'syntax.php'); +
-require_once(DOKU_INC.'inc/fulltext.php');+
  
-/** +<code
- * All DokuWiki plugins to extend the parser/rendering mechanism +{{backlinks>.#include}}
- * need to inherit from this class +
- */ +
-class syntax_plugin_backlinks extends DokuWiki_Syntax_Plugin { +
-    /** +
-     * return some info +
-     */ +
-    function getInfo(){ +
-        return array( +
-            'author' => 'Jonathan Arkell', +
-            'email'  => 'jonnay@jonnay.net', +
-            'date'   => '2005-10-24', +
-            'name'   => 'Backlink Plugin', +
-            'desc'   => 'Displays the backlinks for the given wikipage', +
-            'url'    => '', +
-        ); +
-    } +
-  +
-    /** +
-     * What kind of syntax are we? +
-     */ +
-    function getType(){ +
-        return 'substition'; +
-    } +
-          +
-    /** +
-     * Where to sort in? +
-     */ +
-    function getSort(){ +
-        return 30; +
-    } +
-     +
-    /** +
-     * Paragraph Type +
-     */ +
-    function getPType(){ +
-        return 'block'; +
-    } +
-  +
-    /** +
-     * Connect pattern to lexer +
-     */ +
-    function connectTo($mode) { +
-      $this->Lexer->addSpecialPattern("{{backlinks}}",$mode,'plugin_backlinks'); +
-    } +
-       +
-    /** +
-     * Handle the match +
-     */ +
-    function handle($match, $state, $pos, &$handler){ +
-        global $ID; +
-  +
-        $syntax = substr($match,12,-2);                  // strip markup +
-        $page = $ID; +
-         +
-        resolve_pageid(getNS($ID),$page,$exists); // resolve shortcuts +
-  +
-        // check for permission +
-        if (auth_quickaclcheck($page) 1) return false; +
-  +
-  $links = ft_backlinks($page); +
- +
-        $backlinks = array(); // fix for no backlinks +
- +
-        foreach ($links as $link) +
-        { +
-            $backlinks[substr($link, strrpos($link, ':')+1)] = $link; +
-        } +
-        ksort($backlinks); +
-  +
-        return array($page,$backlinks); +
-    }     +
-  +
-    /** +
-     * Create output +
-     */ +
-    function render($mode, &$renderer, $data) { +
-        if($mode == 'xhtml'){ +
-            $file = wikiFN($data[0]); +
-                    +
-            $renderer->doc .= '<div class="backlinks">'; +
-             +
-            if (!empty($data[1])) +
-            { +
-                $lastLetter = ''; +
-                $pageList = array(); +
-                array_push($data[1]," Dummy Entry"); // ugh.  Hacky Kludge. +
-                foreach($data[1] as $name => $page)                   +
-                    if ($name{0} != $lastLetter) { +
-                        if (!empty($pageList)) { +
-                            $renderer->doc .= '<h3>'.strtoupper($lastLetter).'</h3>'; +
-                            $this->renderPageList($renderer, $pageList); +
-                            $pageList = array(); +
-                        } +
-                    } +
-                    $pageList[] = $page; +
-                    $lastLetter = $name{0}; +
-                } +
-            } else { +
-            $renderer->doc .= "{$data[0]} has no backlinks"; +
-            }  +
-             +
-            $renderer->doc .= '</div>'; +
-            return true; +
-        } +
-        return false; +
-    } +
- +
-    function renderpageList(&$renderer, $pageList) +
-    { +
-        if (empty ($pageList)) { +
-            return; +
-        } +
-         +
-        $renderer->doc .= '<ul>'; +
-        foreach($pageList as $page) { +
-          $renderer->doc .= '<li>'; +
-          $renderer->internalLink($page, $page); +
-          $renderer->doc .= '</li>'; +
-        } +
-        $renderer->doc .= '</ul>'; +
-    } +
- +
-    /** +
-     * Corrects relative internal links and media +
-     */ +
-    function _correctRelNS($instr,$incl){ +
-        global $ID; +
-         +
-        // check if included page is in same namespace +
-        $iNS = getNS($incl); +
-        if (getNS($ID) == $iNS) return $instr; +
-         +
-        // convert internal links and media from relative to absolute +
-        $n = count($instr); +
-        for($i = 0; $i < $n; $i++){ +
-            if (substr($instr[$i][0], 0, 8) == 'internal'){ +
-                 +
-                // relative subnamespace +
-                if ($instr[$i][1][0]{0} == '.'){ +
-                    $instr[$i][1][0] = $iNS.':'.substr($instr[$i][1][0], 1); +
-                     +
-                // relative link +
-                } elseif (strpos($instr[$i][1][0],':') === false) { +
-                    $instr[$i][1][0] = $iNS.':'.$instr[$i][1][0]; +
-                } +
-            } +
-        } +
-        return $instr; +
-    } +
-+
-  +
-//Setup VIM: ex: et ts=4 enc=utf-8 : +
- +
-?>+
 </code> </code>
  
-===== Style =====+Where ''include'' is an absolute namespace. 
 +You can exclude pages from and below a certain namespace only using:
  
-The backlinks are in a ''<div>'' tag of class ''backlinks''.  +<code> 
- +{{backlinks>.#!exclude}}
-<code css+
-/* Styles for the backlinks */ +
-.backlinks +
-+
- margin-bottom: 2em; +
-+
- +
-.backlinks h3 +
-+
- border: 0px solid #000; +
- border-bottom-width: 1px; +
- margin-bottom: 0em; +
-} +
- +
-.backlinks ul +
-+
- margin-left: 5.5em; +
-}+
 </code> </code>
  
-===== Changes ===== +===== FAQ ===== 
-  * 2005-11-11 **v0.1** +  * **Why are my pages not showing up?** Probably your wiki index is out of date, refresh the index. 
-    First Version+  **Are the links sortable ? (ie: alphabetically) ** No. 
 +===== Demo ===== 
 +See https://wild-water.nl/dokuwiki/beschrijvingen/regio/jura for an example
  
-===== To Do ===== 
-  * Add config items of special page prefixes that warrant different lists, (i.e. pages with the prefix "category" get put under a different alphabetized list) 
  
-===== Discussion ===== 
  
-Doesn't seem to work for me. The backlinks marker is just interpreted as a media-link...\\ +===== Changelog =====
-I get it. Just using %%{{backlinks}}%% doesn't work (you'll get a ksort error in preview mode); you need to reference the page: %%{{backlinks>page}}%%. Hmmm, a default would be handy though...+
  
------ +The [[https://github.com/mprins/dokuwiki-plugin-backlinks/commits/master|complete changelog is available]] on GitHub
-The link provided [[http://wiki.jonnay.net/_media/bunny/backlinks.tar?cache=nocache]] deliver a tar.gz file not a tar file so it can't be downloaded using plugin manager. Just need to be renamed. +
------+
  
-This also doesn't work for me. I get an error in line 83 about $backlinks not being an array. If I put an "if is_array($backlinks)..." before the ksort(...) instruction (so far this is all I know about PHP) the error goes away provided the page has no backlinks. If it **has** backlinks, however, I get more errors and the page contents isn't rendered at all. +{{rss>https://github.com/mprins/dokuwiki-plugin-backlinks/commits/master.atom date}}
- +
-Also, I don't know whether this is related or not, but when I click the page link in the top (which should show the backlinks), only the text saying "these are the backlinks..." appear, but not the backlinks themselves. Would someone have any hint on how to make this plugin and/or the standard backlink function work? --- //[[alexgieg@gmail.com|Alexander Gieg]] 2005-12-12 18:51// +
-  * I had that when there were no backlinks to show. I fixed this by changing line 83 in syntax.php from **''ksort($backlinks);''** to **''if ($backlinks!=null)  ksort($backlinks);''**. +
- +
-The plugin seems flaky on the latest nightly builds. Sometimes I get the list of backlinks, sometimes not. Also %%{{backlinks}}%% sometimes works for me. I get the backlinks for the current page. Two improvements would be great: being able to ignore pages globally (i.e., always hide the start page from the backlinks list) and being able to display the page's title instead of its wikiname. +
- +
- +
-Maybe, add some parameters? For example, partially include page texts, restrict to namespace, etc? +
- +
----- +
-Is this plugin not already part of the native dokuwiki code? If so, could this plugin page be removed? It would be confusing finding a plugin for a function DokuWiki is already capable of.  --- //[[matthiasgrimm@users.sourceforge.net|Matthias Grimm]] 2009/08/22 13:01//+
  
-> The purpose of this plugin is to embed the backlinks of a page directly into the text of a wiki page.  --- //[[chi@chimeric.de|Michael Klier]] 2009/08/22 16:22// 
plugin/backlinks.1433818656.txt.gz · Last modified: 2015-06-09 04:57 by 115.93.88.196

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