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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   2207 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, 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