Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Integer value for macros View modes: 
User avatar
Member
Member
John-CymbalInteractive - 10/31/2011 5:01:47 PM
   
Integer value for macros
This may be a simple issue to resolve but I have many webparts that use macros that use the query string or other values. I cannot edit the web part properties of some because I get the validation error "This field requires an integer number".

My macro looks like this:
{%a|(default)0|(equals)0|(truevalue)2%}
And I tried fixing it with this:
{%ToInt({(1)?a|(default)0|(equals)0|(truevalue)2?(1)})%}

Thanks,
John

User avatar
Kentico Support
Kentico Support
janh-kentico - 11/1/2011 2:58:12 AM
   
RE:Integer value for macros
Hi John,

You can use a ToInt macro - “(toint)<default value>”, which converts the result to integer, if not successful, uses the default value.

So, in your case it could be:

{%a|(default)0|(equals)0|(truevalue)2|(toint)0%}

For more information about macro expressions please follow the link below:

http://devnet.kentico.com/docs/5_5r2/devguide/index.html?appendix_a___macro_expressions.htm

Best regards,
Jan Hermann

User avatar
Member
Member
John-CymbalInteractive - 11/1/2011 12:27:47 PM
   
RE:Integer value for macros
Hi Jan,

Thanks for the quick reply. I tried your solution and attempted many permutations of the solution but I could not get this to work. I could create a custom macro for the time being but I do not really feel like writing one every time I need to deal with an integer value.

Thanks,
John

User avatar
Kentico Support
Kentico Support
janh-kentico - 11/2/2011 3:23:41 AM
   
RE:Integer value for macros
Hi John,

This is strange. It works fine on my end. Could you please tell me, where do you use this macro?

Best regards,
Jan Hermann

User avatar
Member
Member
John-CymbalInteractive - 11/7/2011 11:09:07 AM
   
RE:Integer value for macros
Hi Jan,

I am using this code in a Document DataSource control for the "Top N" portion. Basically what I am doing is checking if the query string parameter 't' exists. If it does, select all. If it does not only select the top 2 documents.

John

User avatar
Member
Member
John-CymbalInteractive - 11/7/2011 11:09:56 AM
   
RE:Integer value for macros
***Sorry the parameter 'a'***

User avatar
Kentico Support
Kentico Support
janh-kentico - 11/8/2011 1:19:43 AM
   
RE:Integer value for macros
Hi John,

Oh, I've got it! You probably don't insert your macro through the macro engine (It has to be used, when you want to resolve other types than string). So please click on that little black arrow next to the Top N field and place your macro there. Now it should be working!

Best regards,
Jan Hermann

User avatar
Member
Member
nvpat - 11/21/2011 7:32:09 PM
   
RE:Integer value for macros
I'm seeing this same problem and I still can't get it to work with the solution stated above. I'm using the Version 6 syntax: {%ToInt(DBMakeID, 0)%}

DBMakeID is a custom field on my document. I tried the Version 5.5 syntax and that didn't work either.

I used the Macro Editor to enter the macro. What am I doing wrong?

Thanks.

User avatar
Kentico Support
Kentico Support
kentico_janh - 11/22/2011 2:01:13 AM
   
RE:Integer value for macros
Hello,

Yes, this is a bug. If you are adding the macro through the Macro Editor it shouldn't be validated for an integer value no more... It will be fixed in the next hotfix!

Best regards,
Jan Hermann

User avatar
Member
Member
nvpat - 11/30/2011 1:19:00 PM
   
RE:Integer value for macros
I tried this again after I applied HotFix 6.0.7 and it still gives the same error: This field requires an integer number.

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2011 2:06:27 AM
   
RE:Integer value for macros
Hello,

Regrettably, it is more complex problem, than we thought. We are working on it and it should be fixed in the next hotfix. I am very sorry for any inconvenience.

Best regards,
Jan Hermann