Page Titles as <h1>

If you want all your page titles formatted as <h1> in CMSimple's output, you can put the following function to your cmsimple/functions.php or better cmsimple/userfuncs.php, and call it from the template instead of content().

The function is published under GPLv3. So it comes without any warranty.

function content_h1() {
	global $s, $o, $c, $edit, $adm, $cf;
 
	if (!($edit && $adm) && $s > -1) {
		$cnt = $c[$s];
		$cnt = preg_replace('/<h[1-'.$cf['menu']['levels'].']([^>]*)>'
			.'((<[^>]*>)*)([^<]*)((<[^>]*>)*)<\/h[1-'.$cf['menu']['levels'].']([^>]*)>/i',
			'<h1$1>${2}${4}$5</h1$7>', $cnt, 1);
		$cnt = preg_replace("/".$cf['scripting']['regexp']."/is", "", $cnt);
		return $o.$cnt;
	} else {
		return $o;
	}
}

Christoph Michael Becker

~~DISCUSSION~~

tips_and_tricks/page_titles_as_h1.txt · Last modified: 2018/04/05 14:48 (external edit)
Webdesign: NMuD chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0