%SEARCH{... format="... $count(.*?(---[+][+][+][+] ).*) comments"}%
Prints a count of comments in the page if each comment is a 4th level title
-- ColasNahaboo - 13 May 2005
$count(reg-exp) |
A regular expression pattern to count the number of times it appears in the text of a topic (does not search meta data). In case of a multiple="on" search, the pattern is applied to the line found in each search hit.• Specify a RegularExpression that covers the whole text (topic or line), which typically starts with .*, and must end in .* • Put text you want to count in parenthesis, like $pattern(.*?(from here.*?to here).*) • Example: $count(.*?(---[+][+][+][+]) .*) counts the number of <H4> headers in a page • This example has non-greedy .*? patterns to scan for the first occurrence of a header • Limitation: Do not use .*) inside the pattern, e.g. $count(.*foo(.*)bar.*) does not work, but $count(.*foo(.*?)bar.*) does |
%CALC{"$LISTSIZE(%SEARCH{"BlogComment"
web="Blog" scope="topic"
format="$topic" separator=", " nonoise="on"}%)"}%
-- MichaelDaum - 25 Aug 2005
But actually, I'd like to have a counter varialbe that enumerates the topics found, that is $hit is 1 for the first hit, 2 for the second and so on.
Enumeration should take place AFTER ordering, obviously. Well, this is quite different to the proposal here (in-topic pattern counter). Should do a separate FeatureRequest ...
Hm, the hit counter could be done using css3 selectors but very few browsers implement that.
-- MichaelDaum - 25 Aug 2005
Lynnwood, you could also use the FormQueryPlugin's %MATCHCOUNT% variable that does just this.
(On top of that it's fast but that's off topic
)
-- JosMaccabiani - 25 Aug 2005
Thanks Michael and Jos for the excellent solutions. Once again, I'm convinced that with enough work, you can get CALC to do just about anything. And FormQueryPlugin definitely seems like the way to go for implementing FacetedNavigation, given the number of simultaneous searches this requires.
Still, it seems to me that this feature is useful enough that adding a simple variable to search or formatted search would be worth exploring.
-- LynnwoodBrown - 25 Aug 2005
See also: CountingHeadings
-- ChristopherOezbek - 15 Sep 2005
I would like to propose that this topic be renamed to FormattedSearchRegexCountVariable since that would more accurately describe this feature as implemented. My motivation is to submit a feature request for a simple count variable for FormattedSearch - i.e. returns the number of hits from a search - which I believe the current name of this topic implies.
-- LynnwoodBrown - 23 Feb 2006
Renamed.
-- ArthurClemens - 23 Feb 2006
Thank-you Arthur! Now I can submit a FeatureRequest for a simple FormattedSearchCountVariable.
-- LynnwoodBrown - 23 Feb 2006
| ChangeProposalForm | |
|---|---|
| TopicClassification | FeatureRequest |
| TopicSummary | New $count variable in format argument of formatted searches |
| CurrentState | ReadyForMerge |
| OutstandingIssues | |
| RelatedTopics | |
| InterestedParties | |
| ProposedFor | DakarRelease |
| TWikiContributors | ColasNahaboo |
| I | Attachment | History | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|---|
| |
FormattedSearchCountVariableV1.patch | r1 | manage | 1.5 K | 2005-05-13 - 13:44 | UnknownUser | patch to implement this feature in cairo |