Backlinks Handler
This feature was implemented in the 1.1.6.2. release
See also:
Documentation: BacklinksHandlerInfo.This is the development page for the backlinks handler.
Nothing more than a couple of minor modifications to the WakkaBacklinksHandler.
The handler shows a list of pages linking to the current page.
Given the strong page-dependence of this function, I think it makes more sense to have it work as a handler than an action.
To install it just save the code block below as handlers/page/backlinks.php
Use it as any other handler, appending /backlinks to the page URL.
Note: the backlinks handler is available for testing on this server.
<div class="page">
<?php
/**
* Displays a list of internal pages linking to the current page.
*
* Usage: append /backlinks to the URL of the page
*
* This handler retrieves a list of internal pages linking to the current page.
* It first checks if they exist and prints them on the screen.
*
* @package Handlers
* @subpackage
* @name backlinks
*
* @author {@link http://web.archive.org/web/20040823065044/http://www.wakkawiki.com/MartinBurger Martin Burger} - original idea and code.
* @author {@link http://wikka.jsnx.com/DarTar Dario Taraborelli} - code rewritten, ExistsPage check added, removed links array.
* @version 0.3
* @since Wikka 1.1.6.X
*
* @todo
*
*/
// User-interface: strings
define('PAGE_TITLE','Pages linking to %s');
define('ERROR_NO_BACKLINKS','There are no backlinks to this page.');
// build backlinks list
echo $this->Format('=== '.sprintf(PAGE_TITLE,'[['.$this->tag.']]').' === --- ---');
if ($pages = $this->LoadPagesLinkingTo($this->tag)) {
foreach ($pages as $page) {
if ($this->ExistsPage($page['tag'])) {
print $this->Link($page['tag']).'<br />';
}
}
} else {
print ERROR_NO_BACKLINKS;
}
?>
</div>
<?php
/**
* Displays a list of internal pages linking to the current page.
*
* Usage: append /backlinks to the URL of the page
*
* This handler retrieves a list of internal pages linking to the current page.
* It first checks if they exist and prints them on the screen.
*
* @package Handlers
* @subpackage
* @name backlinks
*
* @author {@link http://web.archive.org/web/20040823065044/http://www.wakkawiki.com/MartinBurger Martin Burger} - original idea and code.
* @author {@link http://wikka.jsnx.com/DarTar Dario Taraborelli} - code rewritten, ExistsPage check added, removed links array.
* @version 0.3
* @since Wikka 1.1.6.X
*
* @todo
*
*/
// User-interface: strings
define('PAGE_TITLE','Pages linking to %s');
define('ERROR_NO_BACKLINKS','There are no backlinks to this page.');
// build backlinks list
echo $this->Format('=== '.sprintf(PAGE_TITLE,'[['.$this->tag.']]').' === --- ---');
if ($pages = $this->LoadPagesLinkingTo($this->tag)) {
foreach ($pages as $page) {
if ($this->ExistsPage($page['tag'])) {
print $this->Link($page['tag']).'<br />';
}
}
} else {
print ERROR_NO_BACKLINKS;
}
?>
</div>
CategoryDevelopmentHandlers
Parse error: parse error, unexpected T_STRING in /home/.kalid/jeremyyip/wiki/handlers/page/backlinks.php on line 25
"Given the strong page-dependence of this function, I think it makes more sense to have it work as a handler than an action. "
Actually, *both* make sense - with the action you can embed the output as a page lement; with the handler you just get information - it just depends on the user's purpose which is best.
So, not a replacement, but a good addition!
Unknown method "page/backlinks.php.php"
AND another thing... I'd like a sidebar of Pages That Link To This Page (with say 10 items in)... which template would I hack to do that, and what would I put in it?
To display a list of backlinks in a sidebar you should use the backlinks action, whose content can be displayed by adding to the source:
echo $this->Action('backlinks');
Wikka pages are built by calling actions/header.php, then the appropriate handler for the page body (handlers/page/show.php is the default one) and then actions/footer.php. Depending on your needs and your stylesheet, you might want to add the line above at any of these steps.
Hope this helps
Btw, we should change ERROR_NO_BACKLINKS to NO_BACKLINKS or something like MESSAGE_NO_BACKLINKS because it is no real error.
I'm using the backlinks action and it won't work on these pages...
http://www.jewelwiki.com/wikka.php?wakka=NearYouAlways
It shows three things backlinking to it, but if you look at http://www.jewelwiki.com/wikka.php?wakka=P20050727
this page also links to the first one but is not listed with the backlinks action.
If I use {{category}}, it lists all pages that include the page title NearYouAlways (which is bad for pages like Stand, the word which is included in several other lyrics pages).
thats a strange behavior, indeed. Could you please open a bug-ticket at http://wush.net/trac/wikka/ ? Including information as mysql-version, php-version (and you do not use mod-rewrite as I can see).
Another thing: are you comfortable with phpmyadmin or something similar, i.e. could you look at "links" table to see if the link between the pages is stored in there? Nils (not logged in)