I'm trying to use phpwiki to set up a FAQ database, which is basically a chapter-subchapter-question-(answer,answer,answer,...) structure. Sometimes, answers fit several questions and questions fit several (sub)chapters, so it is a 'crosslinked tree' structure.
I would like to have a "You are here" function which displays (perhaps via BackLinks?) the SHORTEST PATH BACK TO ROOT (StartPage), so the user can go "up" levels until s?he's back at the start page. I.e. I want to display the shortest path the user would have to click to get 'here', from the root page.
I do realize tree structures are not really what Wiki is about (and the shortest path need not be unique or even defined), but I'd like to have this feature anyway where it _does_ work. ;) I have thought about abusing the BackLinks feature but I don't really know where to start.
Could anybody point me in the right direction?
Cheers,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying to use phpwiki to set up a FAQ database, which is basically a chapter-subchapter-question-(answer,answer,answer,...) structure. Sometimes, answers fit several questions and questions fit several (sub)chapters, so it is a 'crosslinked tree' structure.
I would like to have a "You are here" function which displays (perhaps via BackLinks?) the SHORTEST PATH BACK TO ROOT (StartPage), so the user can go "up" levels until s?he's back at the start page. I.e. I want to display the shortest path the user would have to click to get 'here', from the root page.
I do realize tree structures are not really what Wiki is about (and the shortest path need not be unique or even defined), but I'd like to have this feature anyway where it _does_ work. ;) I have thought about abusing the BackLinks feature but I don't really know where to start.
Could anybody point me in the right direction?
Cheers,
Here's a plugin I coded to generate such a feature. It's not pretty, mainly because I couldn't get the standard Wiki URL function to work correctly.
Example...
<?plugin Navi
HomePage
SubPage1
SubPage2
?>
I figured it made more sense to do it this way rather then have the script always trying to figure out where it is (that rarly ever changes).
Patrick
<?php
class WikiPlugin_Navi extends WikiPlugin
{
function getName()
{
return _('Navi');
}
function getDescription()
{
return _('Display a \'breadcrumb\' style navigation system for this page');
}
function run($dbi, $argstr, $request)
{
$crumbs = array();
$pages = explode("\n", trim($argstr));
foreach ($pages as $page)
{
$page = explode('|', trim($page));
// should use WikiLink(), but I can't figure it out, only returns 'Object'
$crumbs[] = '<a href="'.((isset($page[1]))?$page[1]:$page[0]).'">'.$page[0].'</a>';
}
$pageinfo = $request->getPage();
$html = '>'.implode('::', $crumbs).'::'.$pageinfo->getName();
return HTML::raw($html);
}
}
?>