[Home]WikiPatches/UserGotoBarAsSub

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch makes the UserGotoBar a sub, so you can add links dependant of the current page. It is compatible with the traditional plain string format, so no need to change the config file.

In the config file you may write:

$UserGotoBar = sub {
    my ($id) = @_;
    return "text...$id";
}
instead of
$UserGotoBar = "text...";

The patch is quite simple:


sub GetGotoBar {
  my ($id) = @_;
  my ($main, $bartext);

  $bartext  = &GetPageLink($HomePage);
  if ($id =~ m|/|) {
    $main = $id;
    $main =~ s|/.*||;  # Only the main page name (remove subpage)
    $bartext .= " | " . &GetPageLink($main);
  }
  $bartext .= " | " . &GetPageLink($RCName);
  $bartext .= " | " . &GetPrefsLink();
  if ($UseUpload && &UserCanUpload()) {
    $bartext .= " | " . &GetUploadLink();
  }
  if (&GetParam("linkrandom", 0)) {
    $bartext .= " | " . &GetRandomLink();
  }
  if ($UserGotoBar ne '') {
-    $bartext .= " | " . $UserGotoBar;
+    $bartext .= " | ";
+    $bartext .= (ref $UserGotoBar eq 'CODE') ? $UserGotoBar->($id) : $UserGotoBar;
  }
  $bartext .= "<br>\n";
  return $bartext;
}

--StefanTrcek


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited October 5, 2007 12:18 pm by MarkusLude (diff)
Search: