Item10324: zeroresults="0" doesn't print anything

Priority: Normal
Current State: Closed
Released In: 1.1.3
Target Release: patch
Applies To: Engine
Component: SEARCH
Reported By: PaulHarvey
Waiting For: Main.CrawfordCurrie, Main.PaulHarvey, Main.SvenDowideit
Last Change By: KennethLavrsen
It should emit a numeric "0" if this search comes up with nothing:
%SEARCH{"asdfbargleghjkl" excludetopic="%TOPIC%" type="query" zeroresults="0"}%


I guess the code measures whether something is false instead of whether it's defined

-- PaulHarvey - 07 Feb 2011

mmm, I see what you might expect, but...

from the foswiki 1.0 docco:
zeroresults="off" Suppress all output if there are no hits zeroresults="on", displays: "Number of topics: 0"

vs the foswiki trunk docco: | zeroresults="off" or zeroresults="..."| Suppress/replace all output if there are no hits - can also be set to a FormattedSearch string to customise the output | zeroresults="on" - displays the summary, and number of topics found. "Number of topics: 0" |

now, here's the pain. boolean parameters in foswiki macros are evaluated in a perl-ish (is that orc-ish?) way

so I think the wat to get what you want, is to use NOP or somesuch frown, sad smile

tossing in a unit test to see


%SEARCH{"asdfbargleghjkl" excludetopic="%TOPIC%" type="query" zeroresults="%NOP%0"}%

Result: 0

I'm not sure that we can resolve this safely and consistently with other boolean params - so I wimpled (sic) out and just added a little docco and some unit tests showing the madness.

If you disagree - excellent smile

I think a <nop>/%NOP% is fine. Personally I've always encouraged use of on and off, but I agree with what you've done.

-- PaulHarvey - 18 Feb 2011


ItemTemplate edit

Summary zeroresults="0" doesn't print anything
ReportedBy PaulHarvey
Codebase 1.1.2, 1.1.1, 1.1.0, 1.1.0 beta1, trunk
SVN Range
AppliesTo Engine
Component SEARCH
Priority Normal
CurrentState Closed
WaitingFor CrawfordCurrie, PaulHarvey, SvenDowideit
Checkins distro:8d688f039e11 distro:bd6f5b791fc6
TargetRelease patch
ReleasedIn 1.1.3
Topic revision: r7 - 16 Apr 2011, KennethLavrsen - This page was cached on 01 May 2016 - 05:58.

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