Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > K# help View modes: 
User avatar
Member
Member
lwhittemore-emh - 5/11/2013 9:13:56 AM
   
K# help
How would I string these all together as one macro?
{% if (CurrentUser.IsInRole("Public")) {"FileSecurity = 0"} %}

Thanks in advance

User avatar
Member
Member
lwhittemore-emh - 5/11/2013 9:43:54 AM
   
RE:K# help
WhereCondition='{%if (CurrentUser.IsInRole("Public")) {"FileSecurity = 0"} else if (CurrentUser.IsInRole("Collaborative")) {"FileSecurity = 1 OR FileSecurity = 0"} else if (CurrentUser.IsInRole("MCDC")) {"FileSecurity = 2 OR FileSecurity = 1 OR FileSecurity = 0"} else if (CurrentUser.IsInRole("NEMRRC")) {"FileSecurity = 3 OR FileSecurity = 2 OR FileSecurity = 1 OR FileSecurity = 0"}%}' 


So this is what I have (pelase note that I am not a programmer) This works inside the the where condition on a web part, but WHen I put it in a transformation I get this error.

Incorrect syntax near '%'.
Incorrect syntax near '{'.
Incorrect syntax near '{'.
Incorrect syntax near '{'.
Incorrect syntax near '{'.

User avatar
Member
Member
lwhittemore-emh - 5/11/2013 10:13:02 AM
   
RE:K# help
<p><strong><%# Eval("DocumentName") %></strong></p>
<ul>
<cc1:CMSRepeater ID='document' runat='Server' ClassNames='mcep.File' orderby='nodeorder' CheckPermissions='True' transformationname='mcep.File.Preview' WhereCondition='<%# CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("{%if (CurrentUser.IsInRole("Public")) {"FileSecurity = 0"} else if (CurrentUser.IsInRole("Collaborative")) {"FileSecurity = 1 OR FileSecurity = 0"} else if (CurrentUser.IsInRole("MCDC")) {"FileSecurity = 2 OR FileSecurity = 1 OR FileSecurity = 0"} else if (CurrentUser.IsInRole("NEMRRC")) {"FileSecurity = 3 OR FileSecurity = 2 OR FileSecurity = 1 OR FileSecurity = 0"}%}") %>' />
</ul>


This is what I have now but am still getting errors.

[CMSDataProperties.LoadTransformation]: http://server/CMSTransformations/1e1a773e-be91-4420-bfb4-dde1d676822c/mcep/libraryfile/preview.ascx(3): error CS1026: ) expected


The macro works outside of the transformation but I cannot get it to work in the transformation.

User avatar
Member
Member
lwhittemore-emh - 5/11/2013 12:00:11 PM
   
RE:K# help
<p><strong><%# Eval("DocumentName") %></strong></p>
<ul>
<cc1:CMSRepeater ID='document1' runat='Server' ClassNames='mcep.File' orderby='nodeorder' CheckPermissions='True' transformationname='mcep.File.Preview' WhereCondition='<%# CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("{%if (CurrentUser.IsInRole(\"Public\")) {\"FileSecurity = 0\"} else {\"FileSecurity = 100\"}%}") %>
please let me know.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/13/2013 1:43:38 AM
   
RE:K# help
Hi,

Your approach is right - macros are not supported in ASCX transformations so, you need to resolve them using the AP - ResolveMacros.
Also, the quotes have to be escaped due to the protection against SQL injection.

Anyway, you can try using this syntax:

WhereCondition=<%# "<columnName>='" +  CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("<macro>") +  "'" %>


Best regards,
Juraj Ondrus