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;
44 # The last element in @pagepath is the page itself, so punt that
45 # (These are /parent/ links, after all.)
48 foreach my $dir (@pagepath) {
49 next if $dir eq 'index';
51 $height=($pagedepth - $depth);
53 $title=pagetitle($dir);
55 url => urlto(bestlink($page, $path), $page),
60 "height_$height" => 1,
67 sub pagetemplate (@) {
69 my $template=$params{template};
71 if ($template->query(name => "parentlinks") ||
72 $template->query(name => "has_parentlinks")) {
73 my @links=parentlinks($params{page});
74 $template->param(parentlinks => \@links);
75 $template->param(has_parentlinks => (@links > 0));