Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Hide webpart unless page is at the bottom of the content tree View modes: 
User avatar
Member
Member
matt-awg - 4/8/2013 10:29:04 AM
   
Hide webpart unless page is at the bottom of the content tree
Is there a way to hide a web part from appearing EXCEPT when it is on the bottom of the content tree. Basically I want the product list to only show up on this ecommerce site when the user is on the lowest level of the content tree. Sometimes there may only be one level and sometimes there could be four depending on the category so this has to be dynamic. Maybe I am missing something obvious but I can't find anything in my searching that will do this... any ideas?

Thanks in advance for any help,
Matt

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/8/2013 11:50:10 AM
   
RE:Hide webpart unless page is at the bottom of the content tree
Hi,

If I am right, you want to display the web part only for the document, that does not have any children, right? If so, I would use a context macro and check the number of child documents using macro like this to return true/false value for the Visibility property of the web part:

{%if (CurrentDocument.NodeChildNodesCount > 0) {return false} else {return true}%}

Best regards,
Juraj Ondrus

User avatar
Member
Member
matt-awg - 4/8/2013 12:12:35 PM
   
RE:Hide webpart unless page is at the bottom of the content tree
Hi Juraj,
Thanks for the quick response. I guess technically it is NOT at the bottom of the tree because the products themselves are actually documents in the tree! So unfortunately, your idea does not work. Is there any way to tell that a page has no documents of a certain type as children?
Thanks,
Matt

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/8/2013 12:21:47 PM
   
RE:Hide webpart unless page is at the bottom of the content tree
Hi,

You can play with the macros - using the macro designer you can see what other options - properties, methods are available that will fit your need. E.g. the ChildObjects looks promising.

Best regards,
Juraj Ondrus

User avatar
Member
Member
matt-awg - 4/9/2013 9:04:02 AM
   
RE:Hide webpart unless page is at the bottom of the content tree
Thanks Juraj,

I see the availble options as you suggested but there is no documentation anywhere explaining how to use them. Using the macro designer, some items under CurrentDocument, like cache, at least pop up a brief explanation of what that property or method is used for but "ChildObjects" does not even do that. Searching the Kentico CMS 7.0 API chm file for "ChildObjects" returns nothing, as does searching on devnet.kentico.com (well, except it returns this thread of course). I am not asking for you to do my work for me but it would be much easier if there were some documentation explaining how to actually use the available options. Is there some documentation I am not aware of that would be of help here?

Thanks,
Matt

User avatar
Member
Member
matt-awg - 4/9/2013 1:28:03 PM
   
RE:Hide webpart unless page is at the bottom of the content tree
In case anyone else is curious or trying to do this on their site.... I figured out a way to get this to work (it is not perfect but as close as I could get). What was happening was the product list was showing up on the category page, sub category page, and so on down the tree. My client wants products to only appear at the bottom sub category. I tried using macros in the visibility property but that wasn't working. I realized I could use the "Hide if no record found:" setting to hide the list if there were no products but the problem is the ecommerce site template that the site is based off shows all the products in all sub categories down the tree from the current one. This is because "Maximum nesting level:" is set to -1... changing this to 1 only shows items assigned to the current category and then checking the "Hide if no record found:" hides the list on all but the category where products are directly assigned. The only problem is I can't show the "No record found text:" value for any bottom level category that actually does not have any products - but that category itself should not really be visible anyway (next on my to do list is hiding that type of category from showing up at all).