00736: Incorrect group home page links in pagelists

Summary: Incorrect group home page links in pagelists
Created: 2006-05-06 15:38
Status: Closed - fixed in 2.1.7
Category: Bug
From: NC?
Assigned:
Priority: 453
Version: 2.1.5
OS: Linux/Apache/PHP5

Description: I used pagelist to make an index page of Main.Index which works in some but not all occurrences. When generating a pagelist using the function pagelist fmt=group, the links are not correct for any group that does not have a default page. If the page Example.Example exists then the pagelist correctly makes a link to it, but if the group Example exists without a page named Example beneath it, the pagelist actually creates a link to Main.Example. This creates a lot of confusion.

Alternate description:

The following pagelist has a link to

  PITS/GroupWithNoHomePage?action=edit

but the link should be to either

  GroupWithNoHomePage/HomePage?action=edit

or

  GroupWithNoHomePage/GroupWithNoHomePage?action=edit
(:pagelist GroupWithNoHomePage:)
PITS /
00736  Incorrect group home page links in pagelists (Closed - fixed in 2.1.7)
Site /
AllRecentChangesPerAuthor  All pages changed by Author

Of course similar behavior happens when a group is missing its home page in a form-based search rather than a pagelist. I (Hagan) find this bug annoying but tolerable, however for an inexperienced PmWiki author it must be quite befuddling.

See also Pico's post to the pmwiki-users list.

The possible solutions can be implemented in the PageListTemplates, as discussed below and in my original post to the list, or by creating a new "GroupLink" variable, as discussed in this followup post to the list. Pico May 24, 2006, at 06:20 AM

  • According to PageLists the format I am specifying does exist. I am looking to get a list of just group names without the pagenames. fmt=group correctly does this. The error is that when the default page for a group doesn't exist an incorrect link is generated.

From PageLists:

"predefined fmt parameters:

PmWiki predefines "fmt=simple", "fmt=bygroup", "fmt=title", and "fmt=group". With no fmt= parameter specified the default is by group.

    * fmt=bygroup is the default and produces a pagelist with pages sorted in groups.
    * fmt=simple gives a list of pagenames in the form Group.Name.
    * fmt=title gives a list of page titles. Defaults to order=title to have them sorted by title.
    * fmt=group gives a list of groups, without pagenames. "
  • You are right about the existence and result of fmt=group when a group lacks a default page. In fact, that result occurs for all pagelists that display group names. The underlying problem is that the pagelist directive is creating links that point somewhere. If a group has a default page, then a link to the group points to the default page. If you create groups without default pages, then a link to the group does not have enough information to enable it to point to any (one) page within that group. The pagelist does not fail, however, because PmWiki just treats the link as a link to a page in the current group, applying standard rules that apply for all links. See Links
    • You can test this yourself by creating some links, for instance, a link to Example will point to the group called Example, if that group has a default page, otherwise, it will point to a page called example in the current group.
    • To have a look at what pagelist is actually doing, take a look at the page called PageListTemplates in the Site group. That contains the basic markup that PmWiki uses to generate the pagelist results for fmt=group.
  • With that background, there are two ways to proceed: 1) you can decide to create default pages for all your groups, or 2) you can explore the possibilities and propose an alternative way for pagelist to deal with groups that have no default pages.
    • If what you want is just a listing of groups, without working links, you could change the PageListTemplates on your site to remove the brackets from the third line of fmt=group from * [[{=$Group}]] to {=$Group} and pagelist would generate a text list of groups (where the listed groups would not be links)
    • If you want the pagelist to remain a list of working links, then you can try to come up with some alternatives, perhaps test them out on your Site.PageListTemplates, and share your proposal here. Possible alternatives could work simply by changing the way that group links are defined in PageListTemplates. Currently, the markup for group links is: [[{=$Group}]].
      1. Link to RecentChanges. Since PmWiki creates the RecentChanges page in each group, you could modify the link to point to that page, but display only the group name, by simply changing the group link to [[{=$Group}(.RecentChanges)]].
      2. Link to a search result. Another alternative might be to cause group links to return a search result of the existing pages within that group, by changing the group link to [[{$Name}?action=search&q={=$Group}/|{=$Group}]]
      3. Link to a specified default page. If you decided that every group should have a default page, and if you were willing to choose one format, either Group.HomePage, or Group.Group, then you could change the group link to refer to that default page, like this: [[{=$Group}(.HomePage)]] or [[{=$Group}(.{=$Group})]]. If the default page does not exist, then at least the link will create it in the correct group.
  • If you like any of these, or come up with a better idea for dealing with this situation where pagelist identifies groups without default pages, you should state your preference here. Pico May 08, 2006, at 12:12 PM

Proposals: See items 1 to 3 above for workarounds to avoid the problem of pagelist links for groups without default pages by modifying the group links defined in PageListTemplates. If you could test for the existence of the default page, then any one of these proposals could be conditional. See list thread Pico

I believe that the appropriate solution is the creation of a GroupLink (I prefer GroupPage) type variable, but it should be kept simple so that it can be used even outside of pagelists anytime somone wants to refer to the group homepage without knowing whether it is Group.HomePage or Group.Group. If you want more complex functinonality than that I think that it would be more appropriate to do that in your own Pagelist template. Martin Fick May 24, 2006, at 11:45 AM