This question about Using an extension: Answered

Count topics using an embedded search?

I have a number of topics that follow a naming scheme. I want to show just the number of pages that have a certain word in their topic name, not a list of the actual pages.

The output should be just a number, because I want to embed it inline in other content. I haven't found a way to use formatted search to achieve that, but the TopicCountPlugin does exactly that!

  • I get the wrong count result. While I can do a search to get exactly the right topics, these aren't counted correctly when using TopicCountPlugin.
  • How do I fix this?

Example: Let's say I want to show the number of pages that contain the word Web:

all pages with Web:
%SEARCH{"*" topic="*Web*" excludetopic="*Home" format="$topic" separator=", " nonoise="on"}%
FoswikiOnWebHost1and1, InstallStepConfigureWebServer, InstallStepConfigureWebServerSolaris10, InstallStepConfigureWebServerWindowsApacheActivePerl, WebAtom, WebChangesBoxLikeTwiki, WebCreateNewTopic, WebFormManagement, WebLeftBar, WebLinks, WebNotify, WebPreferences, WebRss
Searched: "*" topic="Web*" excludetopic="*Home" format="$topic" separator=", " nonoise="on"
Number of topics: 0
" }%
Oh no, the plugin isn't installed here so I can't demonstrate the actual result. On my (nonpublic) installation, the result value is 2.
using formatted search:
%SEARCH{"*" topic="Web*" excludetopic="*Home" format="" separator="" nosummary="on" nosearch="on" noheader="on" }%
Number of topics: 9

...but I wanted only the number, not the prefixed label.

You can see that the count result of the search is different from the topiccount result. But they should be identical.

I also tried using TOPICCOUNT with the parameter topic="Web*" but got the same (wrong) result that way. Avoiding the embedded search would be very nice, so if that's an easier solution then I'm eager to see it work.

-- TorbenGB - 05 Apr 2011


Please use QuerySearch

Topics named Web*: 33


QuerySearch explains other operators such as =~ (regex) and further search constraints too.

-- PaulHarvey - 07 Apr 2011

QuestionForm edit

Subject Using an extension
Extension TopicCountPlugin
Version Foswiki 1.1.2
Status Answered
Topic revision: r3 - 07 Apr 2011, PaulHarvey - This page was cached on 05 Jun 2020 - 02:04.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy