Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Only show content if child

Go to End

2 Posts   2056 Views


Community Member, 61 Posts

7 February 2010 at 1:00am

I am wanting to only show some content if the current page is a child of a specific parent. I have tried things like

if Child(home-page)
If Parent == home-page

But not having much luck

Could someone please point me in the right direction?



Community Member, 545 Posts

7 February 2010 at 9:05am

If you're doing this in the Template you have to wrap your if statement in a Parent Control

<% control Parent %>
<% if ClassName == HomePage %>
insert Content
<% end_if %>
<% end_control %>

if You're doing this in a Method in Controller you can get the parent id with $this->ParentID and use that call the parent data object to check the title