diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/parserutils.php | 2 | ||||
-rw-r--r-- | inc/template.php | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/inc/parserutils.php b/inc/parserutils.php index 1dbc1430f..349e83725 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -321,7 +321,7 @@ function p_get_first_heading($id){ $instructions = p_cached_instructions($file,true); foreach ( $instructions as $instruction ) { if ($instruction[0] == 'header') { - return $instruction[1][0]; + return trim($instruction[1][0]); } } } diff --git a/inc/template.php b/inc/template.php index b635f6093..1ee995b5c 100644 --- a/inc/template.php +++ b/inc/template.php @@ -676,5 +676,27 @@ function tpl_mediauploadform(){ ptln('</form>',2); } +/** + * Prints the name of the given page (current one if none given). + * + * If useheading is enabled this will use the first headline else + * the given ID is printed. + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tpl_pagetitle($id=null){ + global $conf; + if(is_null($id)){ + global $ID; + $id = $ID; + } + + $name = $id; + if ($conf['useheading']) { + $title = p_get_first_heading($id); + if ($title) $name = $title; + } + print hsc($name); +} //Setup VIM: ex: et ts=2 enc=utf-8 : |