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);
28 my $title=$config{wikiname};
33 my @pagepath=(split("/", $page));
34 my $pagedepth=@pagepath;
35 foreach my $dir (@pagepath) {
36 next if $dir eq 'index';
38 $height=($pagedepth - $depth);
40 url => urlto(bestlink($page, $path), $page),
45 "height_$height" => 1,
48 $title=pagetitle($dir);
54 sub pagetemplate (@) {
56 my $page=$params{page};
57 my $template=$params{template};
59 if ($template->query(name => "parentlinks") ||
60 $template->query(name => "has_parentlinks")) {
61 my @links=parentlinks($page);
62 $template->param(parentlinks => \@links);
63 $template->param(has_parentlinks => (@links > 0));