Web part visibility based on page type of children

Carolyn Campbell asked on August 9, 2022 23:03

I'm trying to write a macro in the Visibility condition of a web part, where it should be visible if the current page has children only of a certain page type. I've been trying variations of the following, but it's always visible:

{% CurrentDocument.Children.Where(x => x.ClassName == "customPageType") #%}

What am I missing? Thank you!

Correct Answer

vasu yerramsetti answered on August 16, 2022 12:13

Use the below Macro -

{% CurrentDocument.Children.Exists("ClassName==\"CMS.News\"") %}

Refer below screenshot for how to add macro at visible property on your widget.

https://i2.paste.pics/I5PD0.png?trs=669cb31f0abd676c5f82f9562c67352769a82ddd940a62b440f5eebe0dcb782e

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brian McKeiver answered on August 15, 2022 23:30

Did you use the black arrow in between the label Visible and the checkbox on the editor control to ensure it is actually a macro? And make sure after you have saved it a couple times it is an actual not macro, not just text in the box. That has bit me before. I'd even try {% return false %} to see if it hides.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.