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
--
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