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;
36 # The last element in @pagepath is the page itself, so punt that
37 # (These are /parent/ links, after all.)
40 foreach my $dir (@pagepath) {
41 next if $dir eq 'index';
43 $height=($pagedepth - $depth);
45 $title=pagetitle($dir);
47 url => urlto(bestlink($page, $path), $page),
52 "height_$height" => 1,
59 sub pagetemplate (@) {
61 my $page=$params{page};
62 my $template=$params{template};
64 if ($template->query(name => "parentlinks") ||
65 $template->query(name => "has_parentlinks")) {
66 my @links=parentlinks($page);
67 $template->param(parentlinks => \@links);
68 $template->param(has_parentlinks => (@links > 0));