Search code examples
kentico

Hide web part zone containing two repeaters if no child pages exist


I have a Web part zone that have two repeaters. Each repeater uses the same Path '/Processes/%'. What is the best way to hide the entire web part zone if no child pages exist in '/Processes/%' ?

The pages I am checking for do not live directly under the page but under a child page. How do I check for grandchild pages under a specific path ? '/Processes/%' ?


Solution

  • You could use the Documents macro to access the correct document, and check if it has children.

    If the alias path of your Processes page is /Processes, and you want to check if it has child pages (/Processes/%):

    {% Documents["/Processes"].NodeHasChildren %}
    

    If the alias path is /MyPage/Processes (and the children being under /MyPage/Processes/%):

    {% Documents["/MyPage/Processes"].NodeHasChildren %}
    

    You can then use that as a macro on the "Visible" property of your WebPart Zone.