This feature was implemented in the 1.1.6.2. release

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>



CategoryDevelopmentHandlers
Comments
Comment by JeremyYip
2005-01-28 12:07:41
I'm still getting an error message.

Parse error: parse error, unexpected T_STRING in /home/.kalid/jeremyyip/wiki/handlers/page/backlinks.php on line 25
Comment by DarTar
2005-01-28 12:16:50
I suggest you copy the code block from the "source" of this page (http://wikka.jsnx.com/BacklinksHandler/raw), not from this screen, which can accidentally add tabs and characters breaking the code. Let me know if this solves your problem.
Comment by JeremyYip
2005-01-28 12:26:07
That works. I'm use wondering is it possible to have it automatically put the backlinks on top of the page. Kinda like let the visitor know how they managed to get to this page etc...
Comment by DarTar
2005-01-28 13:18:51
Jeremy, you can still use the {{backlinks}} action in the page body: it does exactly what you are looking for.
Comment by GmBowen
2005-01-28 13:49:09
Hmmm....I think what Jeremy is really interested in is the "breadcrumbs" kind of thing that ChristianBarthelemy is considering trying to implement.
Comment by JeremyYip
2005-01-28 14:18:37
Yes... That's exactly what i mean!!1 Thanks GmBowen! The thing is when people go to a page in the wiki. The only way to go back is by using the back button. I was wondering if there could be something on the page... {{backlinks}} does work, but I'm thinking of putting something in the header, under the homepage categories links.
Comment by JavaWoman
2005-01-30 08:11:19
DarTar,
"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!
Comment by ACD77B39.ipt.aol.com
2005-10-12 16:44:51
I added the code to handlers/page and get

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?
Comment by DarTar
2005-10-12 18:38:23
It looks like you saved the code with a double extension (.php.php). If you are on Mac OS X make sure you deselect the "hide extension" option before saving.

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
Comment by VanSciver
2006-03-20 18:57:47
Is there a way of setting an exclusion Parameter for the backlinks action, such that if there is a page linking to another page, but you don't want that page to appear in the list, it can be excluded from the list?
Comment by NilsLindenberg
2006-03-21 02:52:05
No, at the moment not. Since an action parameter (in this case the name of the page) would be visible in the formatting code of the page, it would make no sense. The only thing I can think of is to check if the user has read-access for the pages linking to the page with the action
Comment by VanSciver
2006-03-26 03:28:45
The backlinks handler won't link to my pages that are labeled P######## (where # are numbers)... I don't know if it's a bug or what.
Comment by NilsLindenberg
2006-03-26 05:40:22
It works for me. Have you tried the {{backlinks}} action? Does it work?

Btw, we should change ERROR_NO_BACKLINKS to NO_BACKLINKS or something like MESSAGE_NO_BACKLINKS because it is no real error.
Comment by VanSciver
2006-03-26 12:15:59
Hi Nils,
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).
Comment by 134.76.60.193
2006-03-27 05:15:13
Hi Van,
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)
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki