[pmwiki-users] $PubDirUrl and $FarmPubDirUrl in recipes
Patrick R. Michaud
pmichaud at pobox.com
Sat Nov 10 11:15:19 CST 2007
On Fri, Oct 26, 2007 at 10:24:39AM +0100, Hans wrote:
> I wonder if I should employ $PubDirUrl rather than $FarmPubDirUrl for
> recipes which need some css file in a browser accessible public
I think the best approach might be to use $FarmPubDirUrl if it's
set, otherwise use $PubDirUrl.
Also, it's helpful if the recipe sets its own pubdir variable
(SDV-initialized from either $FarmPubDirUrl or $PubDirUrl).
This makes it easy for an administrator to choose a different
default if using $FarmPubDirUrl isn't correct.
For example, a recipe called XYZ might do something like:
(@$FarmPubDirUrl) ? '$FarmPubDirUrl/xyz' : '$PubDirUrl/xyz');
and then use $XYZPubDirUrl throughout the rest of the recipe.
Then an admin can easily set $XYZPubDirUrl to be something else
if it shouldn't be loaded from the farm.
The WikiStylesPlus recipe goes even further, by checking
the name of the included file to see if it's in the farm
directory (or one of its subdirectories). If so, then it
chooses to use $FarmPubDirUrl, otherwise it uses $PubDirUrl.
(substr(__FILE__, 0, strlen($FarmD)) == $FarmD)
? '$FarmPubDirUrl/wsplus' : '$PubDirUrl/wsplus');
Note that both of the above use single quotes when initializing
the variable. Then $FarmPubDirUrl/$PubDirUrl are substituted into
a generated string (via FmtPageName) when the url is actually
needed in the output.
Hope this helps,
More information about the pmwiki-users