We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Support Web>CountingHeadings (21 Nov 2003, LynnwoodBrown)
Tags:
create new tag
, view all tags

Question

Does anyone know of a simple way one could count and display the number of headings of a certain level(i.e. level 1, level 2, etc) within a topic? I am trying to figure out a simple way to list the number of comments on a topic if all comments were preceeded by a heading of a certain level. Thanks for any thoughts on this.

Environment

TWiki version: TWikiBetaRelease

-- LynnwoodBrown - 20 Nov 2003

Answer

Do a multiple="on" search on the topic for the heading, like "\-\-\-\+\+ ", and count the number of hits with the SpreadSheetPlugin. For this you need the latest TWikiAlphaRelease.

Example:

%SEARCH{ "\-\-\-\+\+ " scope="text" topic="%TOPIC%" regex="on" multiple="on" format="|$text|" nosearch="on" nototal="on" }%
| Total: %CALC{$ROW(-1)}% |

produces this on the current topic:

---++ Question
---++ Environment
---++ Answer
Total: 3

You can hide this table in HTML comments and refer to the total after the commented out table with %CALC{$ROW(-1)}% (gives this: 3)

You can also put the whole thing into a topic you include in other topics (use topic="%INCLUDINGTOPIC%" to point search to the correct topic)

Hope this helps.

-- PeterThoeny - 21 Nov 2003

Wow! I would have never figured that one out on my own and I'm impressed that there was a way to do it at all. Thanks so much, Peter!

-- LynnwoodBrown - 21 Nov 2003

Topic revision: r3 - 21 Nov 2003 - 15:22:51 - LynnwoodBrown
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback