Bug reports Found a bug? Post it here please.
Version 5.x > Bug reports > Nested Macros not resolving View modes: 
User avatar
Certified Developer 11
Certified Developer 11
jason-datausa - 10/13/2010 6:43:35 PM
   
Nested Macros not resolving
I'm currently running v5.5.3873.

I've tried this:
{%if (sh == "7d") { ProcessCustomMacro("7d", "") } else { "" }%}
and it renders this:
|resolve{% ProcessCustomMacro("7d", "") %}


I've tried this:
{%if (sh == "7d") { "" } else { "" }|(default)resolve{%}
and it renders this:
|resolve{% ProcessCustomMacro("7d", "") %}


{% ProcessCustomMacro("7day", "") %} works by itself. It's a custom macros that returns the current date(-7 days) in string form.

Am I missing something on how to nest macros?

Thanks.

User avatar
Certified Developer 11
Certified Developer 11
jason-datausa - 10/13/2010 6:48:32 PM
   
RE:Nested Macros not resolving
Correction:

This:
{%if (sh == "7d") { ProcessCustomMacro("7d", "") } else { "" }%}
and it rendered on the page as this:
{% ProcessCustomMacro("7d", "") %}

It never resolved the nested macros.

User avatar
Certified Developer 11
Certified Developer 11
jason-datausa - 10/14/2010 4:20:11 PM
   
RE:Nested Macros not resolving
I applied the 5.5.21 hot fix and was able to get these nested macros working:

{%if (sh == "7d") { ProcessCustomMacro("7d", "") } else { "" }%}

User avatar
Member
Member
DesignByOnyx - 5/25/2011 12:40:42 AM
   
RE:Nested Macros not resolving
Where is this covered in the documentation?? The documentation only references the

"index parentheses" syntax, e.g. {%FullName|(default){(2)%Username%(2)}%}


However, they never mention the "resolve" parameter you used after your nested macro. The only thing that worked for me was a combination of the "index parenthesis" and this undocumented "resolve" parameter.

These worked:

// ("index parenthesis" AND "resolve" parameter)
{(1)?userid|(equals)|(truevalue)1=1|(falsevalue)DocumentCreatedByUserID = {(2)?userid?(2)}|(resolve)?(1)}

// ("index parenthesis" omitted on nested macro - yes this worked!)
{(1)?userid|(equals)|(truevalue)1=1|(falsevalue)DocumentCreatedByUserID = {%userid%}|(resolve)?(1)}


These did not work:

// (no "index parenthesis")
{%if (userid == "") { "1=1" } else { "DocumentCreatedByUserID = {?userid" }%}|(resolve)?}

// (no "resolve" parameter - this should work as per documentation)
{%if (userid == "") { "1=1" } else { "DocumentCreatedByUserID = " + userid }%}

// (no "index parenthesis" or "resolve" parameter)
{%if (userid == "") { "1=1" } else { "DocumentCreatedByUserID = {?userid" }%}?}

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 5/25/2011 2:08:55 AM
   
RE:Nested Macros not resolving
Hello,

I am sorry, that the macro documentation isn't up to date. However, nearly all the macro parameters are explained in the following article. We are making some changes to the macro engine into the 6.0 version so hopefully there will be also a revision of the documentation of the macros.

Best regards,
Boris Pocatko

User avatar
Member
Member
DesignByOnyx - 5/25/2011 8:51:59 AM
   
RE:Nested Macros not resolving
Thanks for that. I follow the blog, but somehow missed that one.

I would like to make a comment about the nested macros - it doesn't seem like nested macros work UNLESS you use the "resolve" parameter AND "index parenthesis"... and I think the documentation should reflect that. It would have saved me a couple hours of headache. Thanks.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/26/2011 2:24:37 AM
   
RE:Nested Macros not resolving
Hi,

using "index parenthesis" is described in the Macro expressions part of documentation. Nested macros should work without need of use of "resolve" parameter. Could you please tell me which version of Kentico you are using? There was a bug in 5.5 version and nested macros were not resolved correctly, but in 5.5R2 or hotfixed 5.5 version the resolution should work.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
DesignByOnyx - 5/26/2011 8:52:29 AM
   
RE:Nested Macros not resolving
Thank you. I am using 5.5 R2.22 - I updated my code before posting on this forum.

You made me curious, so I just tested the following, and it worked:
{%if (ToInt(currentdocument.nodeid, "") == "0") { "" } else { "Node Alias = " + currentdocument.nodealias }%}


But then I tested the following, and it does not work:
{%if (ToInt(testvar, "") == "0") { "" } else { "Test Var = " + testvar }%}


So it appears to be a bug on the query string macro. Can you confirm?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/31/2011 1:40:01 AM
   
RE:Nested Macros not resolving
Hi,

Recursion in nested query macros is disabled by design because the user (attacker) could insert dangerous content into the macro otherwise.

Best regards,
Ivana Tomanickova