Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Edit value in web part setting View modes: 
User avatar
Member
Member
Halim - 6/3/2009 12:09:07 AM
   
Edit value in web part setting
How do I use the edit value function in web part setting for example the visibility of the web part. When I click to edit the value I can see macros which can be used but how do I use that?

--
Halim Dahlan

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 6/3/2009 2:31:38 AM
   
RE:Edit value in web part setting
Hello,

I am not sure, if I understand correctly your question. You can specify for example if a web part is shown on the current context. If you edit the "visible" the property in the "Visibility" section and select for example macro type: Context value, item: CMSContextCurrentUser, UserIsGlobalAdministrator, the web part is only shown for users, which are logged in as global administrator.

I hope this points you into the right direction.

Best regards,
Boris Pocatko

User avatar
Member
Member
Halim - 10/9/2009 2:48:15 AM
   
RE:Edit value in web part setting
Hi,

Can you show a code snippet on this? Thank you.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/9/2009 3:24:49 AM
   
RE:Edit value in web part setting
Hello,

In the described case the macro would be the following:

{%cmscontext.currentuser.userisglobaladministrator%}

Best regards,
Boris Pocatko

User avatar
Member
Member
Halim - 10/22/2009 1:38:11 AM
   
RE:Edit value in web part setting
Hi,

If I want a webpart to be visible on a particular page i.e. Home only, how do I do that? What is the macro that I can use?

Regards,
Halim Dahlan

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 11/4/2009 7:38:06 AM
   
RE:Edit value in web part setting
Hello,

You could try following macro expression in the location Boris mentioned (Visibility property):

{%cmscontext.currentdocument.documentname == "Home"%}

You can place whatever document name instead of "Home". The webpart will be shown on specified document.

Best regards
Ondrej Vasil

User avatar
Member
Member
Halim - 11/4/2009 7:06:37 PM
   
RE:Edit value in web part setting
Thanks for the explanation Ondrej.

Regards,
Halim Dahlan

User avatar
Member
Member
adrian.mccallion-biznetiis - 8/10/2010 6:58:13 AM
   
RE:Edit value in web part setting
Hi
I need to check to see if the value returned from currentdocument.documentmenuclass is empty.

If it is, I need to set it to green, if not, then set it to the colour returned

Would the following work?

currentdocument.documentmenuclass|(equals)NULL|(truevalue)green|(falsevalue)currentdocument.documentmenuclass

Thanks

Adrian

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/16/2010 9:33:38 AM
   
RE:Edit value in web part setting
Hi,

unfortunatelly, you did not mention where you would like to use this macro. Since you have 4.x version the best way how to achieve your goal is using custom macro.

You can use for example this code:

public static string ResolveCustomMacro(MacroResolver sender, string expression, out bool match)
{
match = false;
string result = expression;

string menuclass = "";



// Add your custom macro evaluation

switch (expression.ToLower())
{
case "setclassname":
match = true;
// Set class name

if (String.IsNullOrEmpty(CMSContext.CurrentDocument.DocumentMenuClass))
{
menuclass = "green";
}
else
{
menuclass = CMSContext.CurrentDocument.DocumentMenuClass.ToString();
}

result = menuclass;
break;
}

return result;
}

and you can call this macro using expression:

{% ProcessCustomMacro("setclassname", "") %}


Since version 5.5 hotfix 10 you can use instead of custom macro following one:

{%if (documentmenuclass == "") { "green" } else { documentmenuclass }%}

Best regards,
Ivana Tomanickova