plugin:backlinks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:backlinks [2015-06-09 04:57] – 115.93.88.196 | plugin:backlinks [2024-01-20 00:46] (current) – [FAQ] 81.220.179.19 | ||
---|---|---|---|
Line 2: | Line 2: | ||
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
- | author | + | author |
- | 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 |
- | similar | + | similar |
- | tags : listing, links, include | + | tags : listing, links, meta, include, backlinks |
+ | downloadurl: | ||
+ | bugtracker : https:// | ||
+ | sourcerepo : https:// | ||
+ | donationurl: | ||
---- | ---- | ||
+ | ===== Installation ===== | ||
+ | Search and install the plugin using the [[plugin: | ||
- | ===== Description ===== | + | **Note** if you came here looking for the old, unmaintained and unspported plugin it is now available at [[plugin: |
- | This is a very simple | + | ===== Configuration ===== |
+ | The plugin | ||
- | {{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 | + | < |
+ | {{backlinks> | ||
+ | </ | ||
- | ===== Plugin ===== | + | You can list the backlinks to the current page by using: |
- | To install, put the following PHP file in ''/ | + | < |
- | > As of Nov 1, 2009, the link above is reported as **Unauthorized(([[http:// | + | {{backlinks>.}} |
- | >> That is **NOT** a mirror version. Jonathan Arkell is the author of the [[: | + | </code> |
- | <code php> | + | You can include pages from and below a certain |
- | <?php | + | |
- | /** | + | |
- | * Backlinks: Show a list of backlinks for the given pagename | + | |
- | * Usage: | + | |
- | * {{backlinks> | + | |
- | * {{backlinks> | + | |
- | * {{backlinks> | + | |
- | * {{backlinks> | + | |
- | * | + | |
- | */ | + | |
- | + | ||
- | if(!defined(' | + | |
- | if(!defined(' | + | |
- | require_once(DOKU_PLUGIN.' | + | |
- | require_once(DOKU_INC.' | + | |
- | /** | + | <code> |
- | * All DokuWiki plugins to extend the parser/ | + | {{backlinks> |
- | * need to inherit from this class | + | |
- | */ | + | |
- | class syntax_plugin_backlinks extends DokuWiki_Syntax_Plugin { | + | |
- | /** | + | |
- | * return some info | + | |
- | */ | + | |
- | function getInfo(){ | + | |
- | return array( | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ); | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * What kind of syntax are we? | + | |
- | */ | + | |
- | function getType(){ | + | |
- | return ' | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Where to sort in? | + | |
- | */ | + | |
- | function getSort(){ | + | |
- | return 30; | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Paragraph Type | + | |
- | */ | + | |
- | function getPType(){ | + | |
- | return ' | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Connect pattern to lexer | + | |
- | */ | + | |
- | function connectTo($mode) { | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Handle the match | + | |
- | */ | + | |
- | function handle($match, | + | |
- | global $ID; | + | |
- | + | ||
- | $syntax = substr($match, | + | |
- | $page = $ID; | + | |
- | + | ||
- | resolve_pageid(getNS($ID), | + | |
- | + | ||
- | // check for permission | + | |
- | if (auth_quickaclcheck($page) | + | |
- | + | ||
- | | + | |
- | + | ||
- | $backlinks = array(); // fix for no backlinks | + | |
- | + | ||
- | foreach ($links as $link) | + | |
- | { | + | |
- | $backlinks[substr($link, | + | |
- | } | + | |
- | ksort($backlinks); | + | |
- | + | ||
- | return array($page, | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Create output | + | |
- | */ | + | |
- | function render($mode, | + | |
- | if($mode == ' | + | |
- | $file = wikiFN($data[0]); | + | |
- | + | ||
- | $renderer->doc .= '< | + | |
- | + | ||
- | if (!empty($data[1])) | + | |
- | | + | |
- | $lastLetter = ''; | + | |
- | $pageList = array(); | + | |
- | array_push($data[1]," | + | |
- | foreach($data[1] as $name => $page) | + | |
- | if ($name{0} != $lastLetter) { | + | |
- | if (!empty($pageList)) { | + | |
- | $renderer-> | + | |
- | $this-> | + | |
- | $pageList = array(); | + | |
- | } | + | |
- | } | + | |
- | $pageList[] = $page; | + | |
- | $lastLetter = $name{0}; | + | |
- | } | + | |
- | } else { | + | |
- | $renderer-> | + | |
- | } | + | |
- | + | ||
- | $renderer->doc .= '</ | + | |
- | return true; | + | |
- | | + | |
- | return false; | + | |
- | | + | |
- | + | ||
- | function renderpageList(& | + | |
- | { | + | |
- | if (empty ($pageList)) { | + | |
- | return; | + | |
- | } | + | |
- | + | ||
- | $renderer-> | + | |
- | foreach($pageList as $page) { | + | |
- | $renderer-> | + | |
- | $renderer-> | + | |
- | $renderer-> | + | |
- | } | + | |
- | $renderer-> | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Corrects relative internal links and media | + | |
- | */ | + | |
- | function _correctRelNS($instr, | + | |
- | 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], | + | |
- | + | ||
- | // relative subnamespace | + | |
- | if ($instr[$i][1][0]{0} == ' | + | |
- | $instr[$i][1][0] = $iNS.':' | + | |
- | + | ||
- | // relative link | + | |
- | } elseif (strpos($instr[$i][1][0],':' | + | |
- | $instr[$i][1][0] = $iNS.':' | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | return $instr; | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | //Setup VIM: ex: et ts=4 enc=utf-8 : | + | |
- | + | ||
- | ?> | + | |
</ | </ | ||
- | ===== Style ===== | + | Where '' |
+ | You can exclude pages from and below a certain namespace only using: | ||
- | The backlinks are in a ''< | + | < |
- | + | {{backlinks>.#!exclude}} | |
- | < | + | |
- | /* Styles for the backlinks | + | |
- | .backlinks | + | |
- | { | + | |
- | margin-bottom: | + | |
- | } | + | |
- | + | ||
- | .backlinks h3 | + | |
- | { | + | |
- | border: 0px solid #000; | + | |
- | border-bottom-width: | + | |
- | margin-bottom: | + | |
- | } | + | |
- | + | ||
- | .backlinks ul | + | |
- | { | + | |
- | margin-left: | + | |
- | } | + | |
</ | </ | ||
- | ===== Changes | + | ===== FAQ ===== |
- | * 2005-11-11 | + | * **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:// | ||
- | ===== To Do ===== | ||
- | * Add config items of special page prefixes that warrant different lists, (i.e. pages with the prefix " | ||
- | ===== Discussion ===== | ||
- | Doesn' | + | ===== Changelog ===== |
- | I get it. Just using %%{{backlinks}}%% doesn' | + | |
- | ----- | + | The [[https://github.com/mprins/dokuwiki-plugin-backlinks/commits/ |
- | The link provided | + | |
- | ----- | + | |
- | This also doesn' | + | {{rss> |
- | + | ||
- | 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..." | + | |
- | * I had that when there were no backlinks to show. I fixed this by changing line 83 in syntax.php from **'' | + | |
- | + | ||
- | 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 | + | |
- | > The purpose of this plugin is to embed the backlinks of a page directly into the text of a wiki page. --- // |
plugin/backlinks.1433818656.txt.gz · Last modified: 2015-06-09 04:57 by 115.93.88.196