[pmwiki-users] Problem with link to page built by includes

Petko Yotov 5ko at 5ko.fr
Sat Jan 28 12:06:22 CST 2017


I'll explain how the page title works.

When a page is displayed, the (:title ...:) markup dynamically sets the 
title, if that markup is written in the page, or if it comes from an 
included page or from a page header/footer.

When a "plus-link" is used, the "page variable" $Title is used, and that 
variable is read from a "page attribute" in the saved disk file.

The page attribute is saved when you save the page, except that some 
directives are disabled, notably "if", "redirect", and "include" (other 
pages or headers/footers).


I'm not sure
- what arguments were considered in the past for this design choice: 
disabling include on save,
- why it was made relatively hard to change: no SDVA() yet after local 
config, and
- what side effects might appear if you change this.

But it is still possible to change it so that the include markup is not 
disabled, by adding to config.php such a block:

function EnableIncludeOnSave() {
   global $SaveAttrPatterns;
   
unset($SaveAttrPatterns['/\\(:(if\\d*|include|redirect)(\\s.*?)?:\\)/i']);
   $SaveAttrPatterns['/\\(:(if\\d*|redirect)(\\s.*?)?:\\)/i'] = ' ';
}
$PostConfig['EnableIncludeOnSave'] = 200;

This will still disable the "if" and "redirect" markups; you shouldn't 
re-enable "redirect" otherwise saving a page with such a markup will 
redirect the browser to the target before the page is saved.

After adding this code block, you still need to edit and save every page 
in order to place its title in the "page attribute". Also, if you change 
the "included" pages that change the title, browsing the "including" 
page will show the new title but you'll still need to edit and save it 
in order for the page attribute, and the plus-links, to be updated.

Petko

---
Change log     :  http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes  :  http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade :  http://www.pmwiki.org/wiki/PmWiki/Upgrades


On 2017-01-26 15:57, Johan Bengtsson wrote:
> I have problem with "Title-links" like this:
> 
> [[RegularPage | +]]  # OK, the link will be the page $Title
> 
> [[PageBuiltByIncludes | +]]  # The link will be PageBuiltByIncludes,
> not the $Title included from other pages.

> I _want_ the included page to set the title.



More information about the pmwiki-users mailing list