2 # Ikiwiki parentlinks plugin.
3 package IkiWiki::Plugin::parentlinks;
10 hook(type => "parentlinks", id => "parentlinks", call => \&parentlinks);
11 hook(type => "pagetemplate", id => "parentlinks", call => \&pagetemplate);
30 page => $config{wikiname},
36 my $title=$config{wikiname};
41 my @pagepath=(split("/", $page));
42 my $pagedepth=@pagepath;
43 foreach my $dir (@pagepath) {
44 next if $dir eq 'index';
46 $height=($pagedepth - $depth);
48 url => urlto(bestlink($page, $path), $page),
53 "height_$height" => 1,
56 $title=pagetitle($dir);
62 sub pagetemplate (@) {
64 my $template=$params{template};
66 if ($template->query(name => "parentlinks") ||
67 $template->query(name => "has_parentlinks")) {
68 my @links=parentlinks($params{page});
69 $template->param(parentlinks => \@links);
70 $template->param(has_parentlinks => (@links > 0));