Similar to /EmbeddedBacklinks, this patch adds a new tag to the wiki markup. The new tag, <subpage> lists all the subpages belonging to the current page. It can also be used as <subpage OtherPage> to list the subpages of a specific other page.
--- wiki.pl 2003-09-11 14:21:02.000000000 +0200 +++ SubpageList.pl 2006-03-01 07:47:21.831646640 +0100 @@ -1572,6 +1572,8 @@ } $pageText = &QuoteHtml($pageText); $pageText =~ s/\\ *\r?\n/ /g; # Join lines with backslash at end + $pageText =~ s/<subpages>/&StoreRaw("<h2>" . Ts('Subpages of: %s', $MainPage) . "<\/h2>\n" . &GetPageList(&GetSubpages($MainPage)))/ige; + $pageText =~ s/<subpages\s+(.*?)>/&StoreRaw("<h2>" . Ts('Subpages of: %s', &QuoteHtml($1)) . "<\/h2>\n" . &GetPageList(&GetSubpages($1)))/ige; if ($ParseParas) { # Note: The following 3 rules may span paragraphs, so they are # copied from CommonMarkup @@ -3736,6 +3738,23 @@ print &GetCommonFooter(); } +sub GetSubpages { + my ($parentPage) = @_; + my ($dir, @subpageFiles, @pages, $subId); + + return '' unless $parentPage; + $dir = GetPageDirectory($parentPage); + opendir(PAGELIST, "$PageDir/$dir/$parentPage") or return ''; + @subpageFiles = readdir(PAGELIST); + closedir(PAGELIST); + foreach $subId (@subpageFiles) { + if (substr($subId, -3) eq '.db') { + push(@pages, "$parentPage/" . substr($subId, 0, -3)); + } + } + return @pages; +} + sub PrintPageList { my $pagename;