Jump to:

23576 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » Only show content if child

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

Page: 1
Go to End
Author Topic: 1558 Views
  • sca123
    Community Member
    61 Posts

    Only show content if child Link to this post

    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?


  • zenmonkey
    Community Member
    528 Posts

    Re: Only show content if child Link to this post

    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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.