[pmwiki-devel] PmWiki Skin and Default name

Petko Yotov 5ko at 5ko.fr
Sat Sep 23 08:31:58 PDT 2023


On 23/09/2023 10:12, Simon wrote:
> Thanks for this awesomely comprehensive reply.
> 
> It seems to me that by setting $DefaultName it should then take
> priority over the default "default"name (i.e. $Group/$Group), and that
> this would be a reasonable expectation for a wiki admin that the "home
> page" of a group would be preferred if there was any disambiguation.
> e.g.
> if (empty ($DefaultName)) then # the default
>      $PagePathFmt = array('{$Group}.$1','$1.$1','$1.{$DefaultName}');
> else # admin changed the 'home page'
>      $PagePathFmt = array(,'$1.{$DefaultName}','{$Group}.$1','$1.$1');
> endif
> 
> Many years ago the decision set set $Defaultname (to 'HomePage') was
> made and its not reversible now

$DefaultName is always defined (to "HomePage" unless you change it in 
config.php, e.g. "Accueil" in French).

Both $DefaultName and $PagePathFmt are initialised before 
local/config.php is included.

They also need to be defined before MakePageName() and ResolvePageName() 
are called, and these may be called from config.php or without your 
knowledge from a recipe.

I would even consider a link such as [[Page]] only linking to a Page in 
the current group, not to Main.Page or Page.Page or Page.HomePage, and 
it would be a "new page" link if it doesn't exist. Something like this:

   $PagePathFmt = array('{$Group}.$1');

Although such a configuration would break many in-page links on our own 
pmwiki.org, and possibly the incoming URLs with only a group without a 
slash like index.php?n=Group


A possible workaround for your problem is to avoid having ambiguous page 
names. Have only one among these:

   Main.Aotearoa
   Aotearoa.Aotearoa
   Aotearoa.HomePage
   OtherGroup.Aotearoa
   AnotherGroup.Aotearoa

And if someone creates such a page, move it to a different name and 
redirect the incoming links.

About the Group/ link in the skin template, to prevent opening an 
existing page Main.Aotearoa when there is a group Aotearoa (with its own 
homepage), in the HTML source you can add a slash after {$Group} like:

 From:
   <a href='{$ScriptUrl}/{$Group}'>{$Group}</a>
To:
   <a href='{$ScriptUrl}/{$Group}/'>{$Group}</a>

This should be tested, there may be some case I don't foresee where this 
breaks something.


I am using fixed "$Group.HomePage" or "$Group.Accueil" homepages in 
large wikis as it is simpler to configure e.g. SiteHeader, SiteFooter, 
and some special recent changes. But as content, I believe 
"$Group.$Group" works better for most cases, in English, on a wiki in 
another language, and on a multi-language wiki - and you may not even 
need to have a (:title...:) directive.

Except specifically "Main.HomePage" seems to me better than "Main.Main". 
Hence I'm happy with the option. :-)

Petko


> On Sun, 20 Aug 2023 at 17:39, Petko Yotov <5ko at 5ko.fr> wrote:
> 
>> Short answer: You can try setting this to config.php:
>> 
>> $PagePathFmt = array('{$Group}.$1','$1.{$DefaultName}','$1.$1');
>> 
>> This will affect the "Name" link in the page header, as well as wiki
>> 
>> links like [[Name/]], [[Name.]], [[Name]] from within the Name
>> group,
>> and [[Name]] from another group.
>> 
>> Long answer:
>> 
>> There is ambiguity when you have pages Name.Name, Name.HomePage,
>> and/or
>> Main.Name. When a link [[Name]] is encountered indeed PmWiki may use
>> a
>> process different from the one in the author's mind. Same for the
>> "Name"
>> link in the page header. Same for (:pagelist list=grouphomes:) and
>> the
>> recently added page variables {$GroupHomePage} and similar.
>> 
>> To calculate the full page name in the case only "Name" (no group)
>> is
>> supplied, the array $PagePathFmt is used, and the first page that
>> exists
>> from that array is returned.
>> 
>> This is the default:
>> $PagePathFmt = array('{$Group}.$1','$1.$1','$1.{$DefaultName}');
>> 
>> When the string "Name" is derived from the URL, such as when the
>> browser
>> follows a group link from a page header, then {$Group} is
>> {$DefaultGroup} (Main) and the URL works like when it was a link
>> [[Name]] in the Main group.
>> 
>> When you have a link [[Name]] in any group, it will process it
>> according
>> to $PagePathFmt. So it will first try CurrentGroup.Name, then
>> Name.Name,
>> then Name.HomePage, and whatever page first exists it will be
>> returned.
>> 
>> For links [[Name/]] or [[Name.]], it knows that "Name" is the group
>> name, but then again if both Name.Name and Name.HomePage exist, it
>> will
>> use the order of $PagePathFmt.
>> 
>> Note that a link [[Name]] in a page of the Name group would point to
>> 
>> Name.Name if it exists (from '{$Group}.$1'), and the same link in
>> another group may point to Name.HomePage.
>> 
>> Also a link [[Name]] in a group different from Name/, and a link
>> [[Name]] "included" in another group from the Name/ group (by
>> (:include:) or a page text variable, or a sidebar) may link to
>> different
>> pages.
>> 
>> We could add a separate array to process the string from the URL (in
>> 
>> ResolvePageName) different from $PagePathFmt that processes links in
>> 
>> pages, but I'm afraid then you may have unexpected results with
>> [[Name/]] and [[Name.]] links.
>> 
>> Alternatively, use Name.Name as the group homepages, and remove the
>> pages Name.HomePage and Main.Name.
>> 
>> Petko
>> 
>> On 20/08/2023 04:09, Simon wrote:
>>> In the PmWiki responsive skin there are the lines
>>> 
>>> <!--PageTitleFmt-->
>>> <div id='wikititle'>
>>> <div class='pagegroup'><a
>>> href='{$ScriptUrl}/{$Group}'>{$Group}</a> /</div>
>>> <h1 class='pagetitle'>{$Title}</h1>
>>> </div>
>>> 
>>> In my config.php I set
>>> $DefaultName = 'HomePage';
>>> 
>>> In my wiki I have two pages
>>> 
>>> MyGroup.HomePage (the landing page for the group)
>>> and
>>> MyGroup.MyGroup
>>> 
>>> Event though I have configured the default name to "HomePage"
>> PmWiki
>>> continues to send page references in the form (specifically in the
>>> page title as shown above)
>>> "MyGroup/ "
>>> to "MyGroup/MyGroup" if the Page "MyGroup.MyGroup" exists, this
>>> doesn't seem right
>>> 



More information about the pmwiki-devel mailing list