This question about Using an extension: Answered
Hi all. I am having a problem that is best summarised as FOSWiki not expanding the CALC variable in a formatted search if another CALC is present in the search. It was described here in 2007 as a bug:
http://foswiki.org/Tasks/Item4798
I've developed an example to demonstrate the problem. In the first search CALC is used to calculate how many hours ago each page was edited. In the second a CALC is just used to spit out a string. In the third both CALCs are used but the result is an unexpanded CALC expression (which is actually properly formed and would work fine if it was expanded!).
If it's a bug is there any workaround someone can suggest? For my application I need to use two CALCs in the search, so a way to force FOSWiki to expand the CALC in the result of the third search would be enough.
Thanks.
%SEARCH{ type="query"
"form.name = 'TestForm'"
web="Sandbox"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="$percntCALC{ | [[$topic]] | $date | Edited $ROUND($EVAL(($TIME()-$TIME($date))/3600)) hours ago |}$percnt"
limit="2"
}%
%SEARCH{ type="query"
"form.name = %CALC{"'TestForm'"}%"
web="Sandbox"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="| [[$topic]] | $date | "
limit="2"
}%
%SEARCH{ type="query"
"form.name = %CALC{"'TestForm'"}%"
web="Sandbox"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="$percntCALC{ | [[$topic]] | $date | Edited $ROUND($EVAL(($TIME()-$TIME($date))/3600)) hours ago |}$percnt"
limit="2"
}%
--
SmCmpbll - 21 Apr 2015
This is an odd and vexing problem but I did find a work-around for you. My first thought was to move your second
CALC
macro into separate defined section and then
INCLUDE it into your search format attribute (and past the "$date" value as a parameter). INCLUDEs normally render the content
before including so I figured this would get us around having 2 CALCs in the same line. At first, I couldn't get this setup to work which completely baffled me. Finally I returned to the docs for
SSP settings and discovered the preference for SPREADSHEETPLUGIN_SKIPINCLUDE which I had never noticed before. This controls whether to expand CALC macro in INCLUDES and defaults to not do so. By turning this off locally or globally, this idea works.
So here's a revised working of your test:
%SEARCH{ type="query"
"form.name = %CALC{"'TestForm'"}%"
web="Sandbox"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="| [[$topic]] | $date | Edited $percntINCLUDE{\"%WEB%.%TOPIC%\" section=\"docalc\" DATE=\"$date\"}$percnt hours ago |"
limit="2"
}%
%STARTSECTION{"docalc"}%%CALC{"$ROUND($EVAL(($TIME()-$TIME(%DATE%))/3600))"}%%ENDSECTION{"docalc"}%
Over-ride default for SSP setting:
* Local SPREADSHEETPLUGIN_SKIPINCLUDE = 0
...with the results being:
--
LynnwoodBrown - 27 Apr 2015
Wow, I had given up hope on this! Thank you so much for finding a work-around (far beyond my capabilities), this will really make a big difference in my web application!
--
SmCmpbll - 27 Apr 2015