[pmwiki-users] [pmwiki-devel] How to count headings?
J. Meijer
commentgg at hotmail.com
Fri Apr 20 15:42:49 CDT 2007
On 4/20/07, Ben Wilson wrote:
> Is there an easy way to count headings in a page? I would like to
configure my site to automatically add the (:toc:) when more than two
headings occur. Or, should this be a feature in Cookbook:PageTOC?
Hi Ben, I use this:
if($action=='browse') {
$pg=ReadPage(ResolvePageName($pagename),READPAGE_CURRENT);
$pg=$pg['text'];
if((preg_match_all('/^!+/m',$pg,$m) and (@count($m[0]) > 2)) or (preg_match_all('/^R:/m',$pg,$m) and @count($m[0]) > 2) ) {
Note the second part of the if(): it also enables toc on FAQ-contents (having R: lines).
HTH
/jm
ps www.dausha.net is unreachable, for months now.
_________________________________________________________________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
More information about the pmwiki-users
mailing list