Questions answered by this recipe
- How can I use a URL with a variable for the root of my Wiki installation path?
- Can I use Markup to make it easy to copy whole Wiki installations to a new address?
- Can I build template Wiki's that don't have the URL hard-coded in the pages with content references?
All sections are optional, you can remove those that do not apply to your recipe, and add new ones.
Add Markup to allow you to insert the root path to your Wiki by referencing a variable in your .../local/config.php file.
This can all be handled in your .../local/config.php file.
To begin, we make a $WikiRoot variable with the proper url/path to the root of your Wiki installation.
Namely the directory where the pmwiki.php file resides, e.g.:
Then, we add markup which uses that Variable to allow you to use it from the Edit Window.
Declare the $WikiRoot variable:
Option 1 -
the typical PMWiki Method.
Add code to declare the $WikiRoot variable and set it to your actual Path.
I recommend just before where you declare the $ScriptURL variable, you add something like this:
$WikiRoot = https://www.myowndomain.org/pmwiki
Obviously you need to replace the example URL with yours. (That should be everything in the Pathname before the /pmwiki.php file)
Option 2 -
use the WikiHost recipe so you don't worry about http vs https and you only declare your path once for the entire installation.
Then you can can declare your WikiRoot with this code:
$WikiRoot = WikiHost.WikiRoot;
Add the Markup
Now, add the following to your .../local/config.php file:
## -- WikiRoot Markup Allows the use of (:WikiRoot:) as part of any URL that includes the root path of your Wiki. ## For Example, you have an image "https://www.myowndomain.org/mypersonaldirectory/pmwiki/media/MyPhoto.jpg" ## You can now use the markup ## (:WikiRoot:)/media/MyPhoto.jpg ## Now even if you move or copy your Wiki install, that URL remains valid! Markup( 'WikiRoot', 'directives', '/\\(:WikiRoot:\\)/',$WikiRoot);
From Edit-Mode in your Wiki you can now type (:WikiRoot:) to get the full URL of the Root of your Wiki
You can combine that with other address parts to create a full URL that acts like a relative URL within your installation.
e.g. instead of writing out the full URL:
You can write:
and it works the same here, but if you copied that page to another wiki (with this recipe) it would work as well!
To do / some day / maybe
If you have future plans or wishes for this recipe.
Change log / Release notes
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".
See discussion at WikiRoot-Talk