[pmwiki-users] Q: preferred way to include wiki pages with recipes

John Rankin john.rankin at affinity.co.nz
Wed Aug 17 19:11:59 CDT 2005


On Thursday, 18 August 2005 10:31 AM, H. Fox <haganfox at gmail.com> wrote:
>On 18 Aug 2005 09:45:26 +1200, John Rankin <john.rankin at affinity.co.nz> wrote:
>> A list discussion a while ago covered the question of how to
>> distribute wiki pages with a skin. Could I get confirmation
>> that the following is the recommended approach for recipes:
>> 
>> 1. place the pages into cookbook/recipe/wikilib.d/
>> 
>> 2. include the following code fragment
>> 
>> function ActivateRecipePageLib($recipe) {
>>   global $WikiLibDirs;
>>   $where = count($WikiLibDirs);
>>   if ($where>1) $where--;
>>   array_splice($WikiLibDirs, $where, 0,
>>     new PageStore("cookbook/$recipe/wikilib.d/\$FullName"));
>> }
>
>Excellent question.
>
>> The function should probably be generalised so 'cookbook'
>> and 'wikilib.d' are variables.
>
>Having a core function is a good idea, but maybe it would be easier /
>more reliable / less ambiguous  to do
>
>    global $WikiLibDirs;
>    $PageStorePath = dirname(__FILE__).'/wiki.d/';
>    $where = count($WikiLibDirs);
>    if ($where>1) $where--;
>    array_splice($WikiLibDirs, $where, 0,
>      array(new PageStore($PageStorePath)));
>
>in the recipe script or skin.php script.
>
>Is
>
>   $PageStorePath = dirname(realpath(__FILE__)).'/wiki.d/';
>
>an improvement, or does realpath() make any difference?
>
>Hagan
>
Perhaps have an array of locations:

function IncludePageLib($location,$recipe) {
    $Locations = array('skin' => '$SkinDir',
                       'cookbook' => '$CookbookDir',
                       'local' => '$LocalDir');
    $PageStorePath = "$Locations[$location]/$recipe/wikilib.d/\$FullName";

I note you suggest wiki.d rather than wikilib.d -- I guess
it doesn't matter which. I thought wikilib.d because the pages 
are part of a library of scripts and I expect they will
include documentation pages, Site configuration pages, and
so on. They can also get updated when a new release comes out,
like regular wikilib.d/ pages.

-- 
JR
--
John Rankin






More information about the pmwiki-users mailing list