[Home]ScriptLink

UseModWiki | RecentChanges | Preferences

UseModWiki/Documentation: Functions: ScriptLink

Returns a string for use as an URL of the current wiki, e.g.

&ScriptLink("action=editprefs", T('Preferences'));

returns:

<a href=\"$ScriptName?action=editprefs\">Preferences</a>


At present ScriptLink does not use $FullUrl, it gives a relative url based on the scriptname. In fact a quick look at the code suggests that the only place $FullUrl is used is when a redirect occurs.

Is this deliberate or an oversight?

I would like to be able to force wiki to generate the link

http://xxxx/xxxx/?PageName

which works fine when typed into either Linux Netscape or Konqueror. But it delivers back all the links as

http://xxxx/xxxx/index.cgi?PageName

because the sub looks at $ScriptName rather than $FullUrl.

Alternatively, is there any reason not to set $ScriptName from the tail of $FullUrl when given? That way $ScriptLink automatically gives relative links (as at present) but with the script as given by the config setting. Suggested code, at around line 312 of wiki.pl

  sub InitRequest {
  my @ScriptPath = split('/', "$ENV{SCRIPT_NAME}");

  $CGI::POST_MAX = $MaxPost;
  $CGI::DISABLE_UPLOADS = 1;  # no uploads
  $q = new CGI;

  $Now = time;                     # Reset in case script is persistent
  $ScriptName = pop(@ScriptPath);  # Name used in links
  $ScriptName = $1 if ( $FullUrl =~ ?.*/(.*)? );  ###### new line
  $IndexInit = 0;                  # Must be reset for each request
  $InterSiteInit = 0;

This correctly produces relative links starting with a "?" when the given $FullUrl ends with a "/". They work in Netscape and Konqueror.

--RiVer

Relative links may be difficult if one uses rewrite rules. Then it might be easier to set $FullUrl in the config file and set $ScriptName to $FullUrl in the script:

  $Now = time;                     # Reset in case script is persistent
  $ScriptName = pop(@ScriptPath);  # Name used in links
  $ScriptName = $FullUrl if ($FullUrl ne ''); ## added
  $IndexInit = 0;                  # Must be reset for each request
  $InterSiteInit = 0;

--MarkusLude


UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited May 22, 2006 2:59 am by MarkusLude (diff)
Search: