[pmwiki-users] Cookbook path
Patrick R. Michaud
pmichaud at pobox.com
Wed Feb 13 11:37:15 CST 2008
On Sun, Feb 10, 2008 at 05:52:30PM -0500, DaveG wrote:
> I'm writing a Cookbook (or Recipe, I never know which is which), and I
> need to get the URL of the location that the script is executing from --
> basically the cookbook directory. This way gets me the script *path*
> (not the URL), which isn't quite what I need:
> The best I have so far is this (extracted from pmwiki.php), but that
> assumes the location of cookbook directory.
> preg_replace('#/[^/]*$#', '/cookbook', $ScriptUrl, 1)
> Anyone done this before?
In the most general case it's not possible to automatically determine
the url of an executable script. This is why PmWiki has to "guess"
at values of $ScriptUrl and $PubDirUrl when it is invoked, but sometimes
guesses wrong if the system has been configured with url aliasing
or CleanUrls or any number of other items that may change the url-to-file
That said, if you have files that you want to be available directly
via the webserver from a url, then those files really belong in
the 'pub/' subdirectory and not in 'cookbook/'. And you can presume
that $PubDirUrl is properly set (either automatically or manually by
the admin) to the url that corresponds to the pub/ directory.
Hope this helps,
More information about the pmwiki-users