Jump to:

22972 Posts in 11596 Topics by 2824 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: 1439 Views
  • sca123
    Avatar
    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?

    Thanks

  • zenmonkey
    Avatar
    Community Member
    524 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

    1439 Views
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.