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, biapar, Willr, Ingo, swaiba, simon_w

Only show content if child


Reply


2 Posts   1626 Views

Avatar
sca123

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?

Thanks

Avatar
zenmonkey

Community Member, 532 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