A modified version, based on this page, are to be implemented in version 0.24. It will allow for multiple childs, and will add the path to the toolbar. --EvenHolen

There are 2 parts to this, which can be used independently or together. A parent-page child-page structure is of the form ParentPage/ChildPage.

Result: using the TaviPatches page as an example, if this patch is installed, an author types /SubPages and 'Tavi treats it as TaviPatches/SubPages. The toolbar on this page includes a link to TaviPatches.

Entering ((/some text)) is the free link equivalent and produces a link to TaviPatches/some text.

JohnRankin


Add parent page to toolbar

Edit parse/html.php and add the following above function html_toolbar_top():

function html_parent_top($page)
{
  return html_ref($page, $page) . ' | ';
}

Edit template/common.php and add the following after the two $keywords statements:

  $parentname = substr($args['headlink'], 0, strpos($args['headlink'], '/'));

Look for if($args['toolbar']) and change it to read:

  if($args['toolbar'])
    { if ($parentname != "") { print html_parent_top($parentname); }
      print html_toolbar_top();
    }

On this page, the result would be to add a link to TaviPatches to the start of the toolbar line.


Recognize child-page markup

Edit parse/transforms.php and modify parse_wikiname and wikiname_token as follows (you can also modify freelink_token if desired):

function parse_wikiname($text, $validate = 0)
{
  global $LinkPtn, $EnableWikiLinks;

  if(!$EnableWikiLinks) { return $text; }
// include a check for sub-page markup
  if($validate)
    { $ptn = "/(^|[^A-Za-z])(\\/?$LinkPtn)(())(\"\")?/e"; }
  else
    { $ptn = "/(^|[^A-Za-z])([!\\/]?$LinkPtn)((\#[A-Za-z]([-A-Za-z0-9_:.]*[-A-Za-z0-9_])?)?)(\"\")?/e"; }

  return preg_replace($ptn,
                      "q1('\\1').wikiname_token(q1('\\2'),'\\4')",
                      $text, -1);
}

function wikiname_token($name, $anchor)
{
  global $ParseObject;

  if($name[0] == '!')                   // No-link escape sequence.
    { return substr($name, 1); }        // Trim leading '!'.
// translate sub-page markup into a qualified wikiword
  if (($name[0] == '/') && !(strpos($ParseObject, '/')))
    { $name = $ParseObject . $name; }
  return new_entity(array('ref', $name, $name, '', $anchor, $anchor));
}

With this patch, on the TaviPatches page I could have written /SubPages and 'tavi would have rendered it as TaviPatches/SubPages. A parent-page is prevented from including a "/" character. See below for an option that supports nested pages.

Administrators may prefer to translate /ChildPage to retain the display as typed, but treat as a link to ParentPage/ChildPage. Do the following:

function wikiname_token($name, $anchor)
{
  global $ParseObject;

  if($name[0] == '!')                   // No-link escape sequence.
    { return substr($name, 1); }        // Trim leading '!'.
// translate sub-page markup into a qualified wikiword
  $link = $name;
  if (($name[0] == '/') && !(strpos($ParseObject, '/')))
    { $link = $ParseObject . $name; }
  return new_entity(array('ref', $link, $name, '', $anchor, $anchor));
}

You can make an identical change to freelink_token if desired.


Enable nested child-pages

Nested subpages require that the child-page not contain a / character.

Edit template/common.php and add the following after the two $keywords statements (note it's strrpos to read backwards from the end):

  $parentname = substr($args['headlink'], 0, strrpos($args['headlink'], '/'));

and

function wikiname_token($name, $anchor)
{
  global $ParseObject;

  if($name[0] == '!')                   // No-link escape sequence.
    { return substr($name, 1); }        // Trim leading '!'.
// translate sub-page markup into a qualified wikiword
  if (($name[0] == '/') && !(strpos(substr($name, 1), '/')))
    { $name = $ParseObject . $name; }
  return new_entity(array('ref', $name, $name, '', $anchor, $anchor));
}

A config.php variable can also be used to enable/disable this feature:

$EnableSubpages = 0; no subpages. $EnableSubpages = 1; one level of subpage. $EnableSubpages = 2; nested subpages.

Spacing child page names

An extra patch is needed for sites that render WikiWords as Wiki Words. Edit parse/html.php and look for function html_ref. Insert the second if statement below.

    if($SeparateLinkWords && $page == $appearance)
      { $appearance = html_split_name($page); }
    if($SeparateLinkWords && $appearance[0]=="/")
      { $appearance = html_split_name($appearance); }

Suggested default

Our site sets $EnableSubpages to 1 and uses the "link as ParentPage/ChildPage, render as /ChildPage" option. Comments welcome -- JohnRankin.

Q: How is the subpages included, if they are, on the ParentPage? Do you need to manually edit that page separately?

A: SubPages are not included, so one has to maintain the parent page separately.


Could you provide an example to a site that supports this? I'm not sure I understand what this does. Is it like my idea for MenuTitles? - gramsci

Yes, i do believe it is. A site will be provided when I get around to setting up a test site--EvenHolen

A site implementing a form of subpages currently online is http://www.logilogi.org