Recent Changes - Search:

PmWiki

pmwiki.org

00266

Summary: (:include:) and (:title:)
Created: 2005-01-05 06:11
Status: Closed - not a bug
Category: Bug
From: Han
Assigned:
Priority: 43
Version: 2.0. beta14
OS: Mac OSX 10.3.7, Apache 2.0.52, PHP4.3.9

Description: When you use (:title:) on page A and (:include:) that page in page B, page B gets the title of page A.


Well, yes, one would expect that any directives in an included page (B) would affect the page that includes it (A). What should happen?

Note that PmWiki uses the last (:title:) directive it sees.

Anyway, I'm not entirely sure this is a bug. Maybe.

If you know that B's title directive is the first line of the file, you could always do (:include B lines=2..:) to skip the first line...


With the latest 2.2.0 version of PmWiki, I've "solved" this problem by using the following conditional code in the include file. With 2.2.0 and the $EnableRelativePageVars turned on, {$FullName} returns the name of the viewed page, not the included page, so the if construct is only true when you are viewing the include file itself.

(:if name {$FullName}:)
(:title This is the title for the Include File:)
(:description This is the description for the Include File:)
(:ifend:)

Adding the following to config.php will define the title markup so that "the first title encountered wins", subsequent title directives (on included pages or otherwise) will be ignored:

## (:title ...:) First title wins, any subsequent (:title ...:) is ignored.
Markup('title','directives',
  '/\\(:title\\s(.*?):\\)/ei',
  "SetTitleMarkup(\$pagename, PSS('$1')) ");
function SetTitleMarkup($pagename, $arg) {
   static $tset = 1;
   if ($tset==1)
       PCache($pagename, $zz=array('title' => SetProperty($pagename, 'title', $arg )));
   $tset++;
}

HansB January 27, 2008, at 05:24 AM


When there are multiple titles on a page (including included titles) the last one is the title displayed. From mailing list it is suggested that

  1. the outermost included title should be used in preference to deeper included titles
  2. the top (first) title should be used
Edit - History - Print - Recent Changes - Search
Page last modified on January 27, 2008, at 01:17 PM