Recent Changes - Search:

PITS main list

edit sidebar

Main sidebar

PmWiki

pmwiki.org

00266

Summary: Last title encountered wins, it should be first title markup
Created: 2005-01-05 06:11
Status: Closed - added $EnablePageTitlePriority for 2.2.9
Category: CoreCandidate
From: Han
Assigned:
Priority: 5554443
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.

Same problem than PITS.00779. Maybe not strictly a bug, but it runs totally across intuition that a later title markup, for instance from an included page, will win over the first title markup. Authors will intuitively set a title markup at the page beginning, not the end! Cookbook.TitleMarkup shows a solution, but it ought to be in the core I think. - HansB July 04, 2008, at 12:55 PM


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

The overall winner will be GroupFooter.
Of course, with the recipe from above GroupHeader will make it.

Another funny thing when using pagelist with fmt=#title and similar is:
If the page to be listed has no title set but (:includes:) a winning one...
Guess which title will be displayed?
Yes, but only when the losing page is the current page and the last included page is the winning one. If the last included page has no title the pagelist is fine.
Of course if you switch to recipe first title wins it's the first page.

Is this a feature or a bug?
Tontyna January 16, 2009


One can redefine the title markup in config.php:
Markup('title','directives',
  '/\\(:title\\s(.*?):\\)/ei',
  "IsEnabled(\$GLOBALS['PCache'][\$pagename]['=p_title'], false)>''? '': PZZ( PCache(\$pagename,
         \$zz=array('title' => SetProperty(\$pagename, 'title', PSS('$1')))) )");
Then the first encountered title directive "wins". See also PITS.00779 for a way to exclude title directives from included pages. --Petko February 03, 2009, at 01:30 AM

Petko - your markup has the effect when I test it that any subsequent title markup is rendered as 1. Also, if you see a problem with the markup I suggested please let me know, because I have not yet! - HansB February 03, 2009, at 06:09 AM

Thanks, I believe it is now corrected. For some unknown reason on my home wiki there were problems with your code. I now tested it on a live site and it works too. --Petko February 03, 2009, at 06:55 AM


It seems to me that if a PTV, or title (or similar directive) exists in both the source page, and in included pages, the source page instances should have preference.

After that, if there are multiple instances, I'll go with the flow, but I not that it is intuitive that the last encountered wins (this also allows for conditional expressions to work correctly) and is in line with CSS etc.

Simon

I totally agree with Simon. - Rogutės

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:56 AM