Insert backlinks directly into the page text. Use <back> to add backlinks to the current page, and <back PageName?> for backlinks to any other page.
This is very useful for category-type pages, which usually state "click on the page title for pages that fall into this category". Now you can make this automatic.
See also: /EmbeddedSubpageList
--- wiki.pl 2003-09-11 14:21:02.000000000 +0200
+++ BackLinks.pl 2006-12-25 09:36:31.359855960 +0100
@@ -65,7 +65,7 @@
$ConfigError $UploadPattern );
# == Configuration =====================================================
-$DataDir = "/tmp/mywikidb"; # Main wiki directory
+$DataDir = "/home/upi/olpan"; # Main wiki directory
$UseConfig = 1; # 1 = use config file, 0 = do not look for config
$ConfigFile = "$DataDir/config"; # Configuration file
@@ -1572,6 +1572,8 @@
}
$pageText = &QuoteHtml($pageText);
$pageText =~ s/\\ *\r?\n/ /g; # Join lines with backslash at end
+ $pageText =~ s/<back>/&StoreRaw("<h2>" . Ts('Backlinks for: %s', $MainPage) . "<\/h2>\n" . &GetPageList(&SearchTitleAndBody($MainPage)))/ige;
+ $pageText =~ s/<back\s+(.*?)>/&StoreRaw("<h2>" . Ts('Backlinks for: %s', &QuoteHtml($1)) . "<\/h2>\n" . &GetPageList(&SearchTitleAndBody($MainPage)))/ige;
if ($ParseParas) {
# Note: The following 3 rules may span paragraphs, so they are
# copied from CommonMarkup
@@ -3736,14 +3738,23 @@
print &GetCommonFooter();
}
+sub GetPageList {
+ my ($pagename, $retval);
+ my (@list) = @_;
+
+ foreach $pagename (@list) {
+ $retval .= ".... " if ($pagename =~ m|/|);
+ $retval .= &GetPageLink($pagename) . "<br>\n";
+ }
+
+ return $retval;
+}
+
sub PrintPageList {
my $pagename;
print "<h2>", Ts('%s pages found:', ($#_ + 1)), "</h2>\n";
- foreach $pagename (@_) {
- print ".... " if ($pagename =~ m|/|);
- print &GetPageLink($pagename), "<br>\n";
- }
+ print GetPageList(@_);
}
sub DoLinks {
@@ -4101,8 +4112,9 @@
sub SearchTitleAndBody {
my ($string) = @_;
- my ($name, $freeName, @found);
+ my ($name, $freeName, @found, $openPageName);
+ $openPageName = $OpenPageName;
foreach $name (&AllPagesList()) {
&OpenPage($name);
&OpenDefaultText();
@@ -4116,6 +4128,10 @@
}
}
}
+ if ($openPageName) {
+ &OpenPage($openPageName);
+ &OpenDefaultText();
+ }
return @found;
}
Previously we had some issues with /EmbeddedBacklinks colliding with the <toc> and the last edited info. This has been fixed now. Thanks for those who have reported it.