This question about Using an extension: Answered

each time I use %CALC% inside %IFDEFINEDTHEN% I get additional }% in page text

If I write code like this:
%CALC{"$SET(sys_webs, %FLEXWEBLIST{include="%BASEWEB%(/\w+)?" subwebs="only" separator=","}%)"}%

PREVLINE
%IFDEFINEDTHEN{"%CALC{"$GET(sys_webs)"}%"}%
not empty
%ELSEDEFINED%
empty
%FIDEFINED%

when I display this page - everything works ok. But when I include it - then things start to break. My output is:

PREVLINE"}% not empty 

Each time I include page with IFDEFINEDTHEN plugin - I get additional }% string in page text. And it's not connected with FLEXWEBLIST plugin - whatever I put inside sys_webs variable gets the same result.


You have to escape the % otherwise the parser cuts it improperly:
%CALC{"$SET(sys_webs, %FLEXWEBLIST{include="%BASEWEB%(/\w+)?" subwebs="only" separator=","}%)"}%
%IFDEFINEDTHEN{"%CALC{"$GET(sys_webs)"}%"}%
Will be parsed as:
%CALC{"$SET(sys_webs, %FLEXWEBLIST{include="%BASEWEB%(/\w+)?" subwebs="only" separator=","}%  here your CALC will end, and then it will print out the rest, so )"}%
. Same for your second example.

So, if you want to use some
%MACRO{ params }% inside another one, simply replace the % sign with $percnt, so:
<verbatim>
%CALC{"$SET(sys_webs, $percntFLEXWEBLIST{include="%BASEWEB%(/\w+)?" subwebs="only" separator=","}$percnt)"}%
%IFDEFINEDTHEN{"$percntCALC{"$GET(sys_webs)"}$percnt"}%
</verbatim>
And it should work.

-- Main.OlivierRaginel - 11 Dec 2009

QuestionForm edit

Subject Using an extension
Extension IfDefinedPlugin
Version Version in SVN
Status Answered
Topic revision: r2 - 11 Dec 2009, OlivierRaginel
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