Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Hide a web part by document id - use macros? View modes: 
User avatar
Member
Member
webmaster-gohighlandgroup - 8/18/2009 2:31:21 PM
   
Hide a web part by document id - use macros?
I have a web part in my master page that needs to be hidden on a few pages in my site. Can I use macros to do that? I tried entering {%currentpageinfo.documentid=7%} in the macro for "Hide on subpages" but it doesn't seem to work. Any ideas of how I can do it or what I'm doing wrong?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/19/2009 5:50:49 AM
   
RE:Hide a web part by document id - use macros?
Hi,

you need to set a macro for the Visible property, it can look like this (the macr must return true/false value):

{%cmscontext.currentdocument.documentname|(notequals)home%}

I hope it will help. For more about macro expressions please see the Developer's guide.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
webmaster-gohighlandgroup - 8/19/2009 10:42:34 AM
   
RE:Hide a web part by document id - use macros?
Wow, I was way off. That helped quite a bit but I still can't figure out how to do exactly what I want. I used this to hide the web part on one page but I'd like to hide it on several different pages. Bellow is how I hid it on one page:
{%currentpageinfo.documentid|(equals)7%}
This didn't work.

Anyone have any ideas?

Thanks

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 8/19/2009 1:55:39 PM
   
RE:Hide a web part by document id - use macros?
Hello,

in this case you would need to develop a custom macro which would contain a condition about current document id and return true or false according its value. The sample code of custom macro is in the article which Juraj mentioned (http://devnet.kentico.com/docs/devguide/index.html?appendix_a___macro_expressions.htm)

Best regards,
Helena Grulichova

User avatar
Member
Member
webmaster-gohighlandgroup - 8/19/2009 3:33:07 PM
   
RE:Hide a web part by document id - use macros?
Thank you so much. Custom macro did it. This is what I came up with:
case "hidefdicfortboh":
match = true;
if (CMS.CMSHelper.CMSContext.CurrentPageInfo.GetValue("DocumentId").ToString() == "7" || CMS.CMSHelper.CMSContext.CurrentPageInfo.GetValue("DocumentId").ToString() == "13" || CMS.CMSHelper.CMSContext.CurrentPageInfo.GetValue("DocumentId").ToString() == "55" || CMS.CMSHelper.CMSContext.CurrentPageInfo.GetValue("DocumentId").ToString() == "56")
result = "true";
else
result = "false";

break;

User avatar
Member
Member
Willy - 6/29/2011 4:26:07 AM
   
RE:Hide a web part by document id - use macros?
I have this page menu structure

- about us
- page 1
- page 2
- page 3

- career

i have added a cmstreemenu webpart on template1, career page is also using template1. i want to display the webpart only to pages under about us page.

i've tried to use the follow but it doesn't work;

{%{%cmscontext.currentdocument.documentnamepath%}

i've also tried urlpath but i just can't make it work.

please help.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 6/29/2011 8:40:38 AM
   
RE:Hide a web part by document id - use macros?
Hello,

I would you suggest you to try to resolve the {%cmscontext.currentdocument.documentnamepath%}

For more information on macros please check this blog post.

Best regards,
Boris Pocatko