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

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2003-11-21 - LynnwoodBrown
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.