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);
12 hook(type => "getsetup", id => "parentlinks", call => \&getsetup);
31 page => $config{wikiname},
37 my $title=$config{wikiname};
42 my @pagepath=(split("/", $page));
43 my $pagedepth=@pagepath;
44 foreach my $dir (@pagepath) {
45 next if $dir eq 'index';
47 $height=($pagedepth - $depth);
49 url => urlto(bestlink($page, $path), $page),
54 "height_$height" => 1,
57 $title=pagetitle($dir);
63 sub pagetemplate (@) {
65 my $template=$params{template};
67 if ($template->query(name => "parentlinks") ||
68 $template->query(name => "has_parentlinks")) {
69 my @links=parentlinks($params{page});
70 $template->param(parentlinks => \@links);
71 $template->param(has_parentlinks => (@links > 0));