|
Cookbook /
TitleMarkupSummary: setting a page title with the first title markup, subsequent titles (from included pages etc.) are ignored
Version: 2008-01-27
Prerequisites: PmWiki 2
Status:
Maintainer:
Categories: Administration Markup
Questions answered by this recipeHow can I set page titles so included pages will not override my titles? DescriptionThis is an alternative title markup definition setting the title with the first title directive. 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. Any $ indicating some variable injection is also defused (while page variables and page text variables will continue to work inside the markup):
## (: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;
$arg = str_replace('$','$',htmlspecialchars($arg, ENT_NOQUOTES));
if ($tset==1)
PCache($pagename, $zz=array('title' => SetProperty($pagename, 'title', $arg )));
$tset++;
}
NotesRelease Notes
See Also
ContributorsCommentsThis recipe was something I really needed. (:title Just a Title Text:) Which title will win? (:markup:) (:include PageWithTitle:) (:markupend:) resulting in having the title of the included PageWithTitle. Yes, So I made another recipe SignalWhenMarkup that sets a counter to signal when we are in
function SetTitleMarkup($pagename, $arg) {
global $SignalMarkupMarkup;
static $tset = 0;
if (!$SignalMarkupMarkup) $tset++;
if ($tset==1) {
$arg = str_replace('$','$',htmlspecialchars($arg, ENT_NOQUOTES));
PCache($pagename, $zz=array('title' => SetProperty($pagename, 'title', $arg )));
}
}
Tontyna February 01, 2009, at 03:22 PM |