Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » If Page Type?

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: 3408 Views
  • corkg
    Avatar
    Community Member
    30 Posts

    If Page Type? Link to this post

    Hi
    I have the following code that displays all children:
    <% control Children %>
    How do I limit this to a certain page type?

    For instance "NewPageType"
    Tried this and It did not work <% if NewPageType %>

    Thanks

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: If Page Type? Link to this post

    Hi.

    Have a look at this:

    <% control ChildrenOf(page-url) %>

    This will create a datafeed of the children of the given page. Handy if you want a list of the subpages under staff (eg the staff) on the homepage etc

    <% control Page(my-page) %>$Title<% end_control %>

    “Page” will return a single page from the site tree, looking it up by URL. You can use it in the <% control %> format. Can’t be called using $Page(my-page).Title.

    Taken from here: http://doc.silverstripe.org/doku.php?id=built-in-page-controls

    Cheers,
    Christian

  • corkg
    Avatar
    Community Member
    30 Posts

    Re: If Page Type? Link to this post

    Thanks,

    Unfortunatly it did not work for me I put in
    <% control Children(NewPage Type) %>
    and it did not restrict the other pages.

    Any other ideas?

    Gareth

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: If Page Type? Link to this post

    Hi eorkg

    You can do this:

    <% if ClassName = PageType %>

  • corkg
    Avatar
    Community Member
    30 Posts

    Re: If Page Type? Link to this post

    I dont understand how to use this.
    Can you interpret this in the context of NewPageType
    I dont understand how classtype fits in

    Thanks

  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: If Page Type? Link to this post

    corkg, I havent tested this, but in your case, it should be:

    <% if ClassName = NewPageType %>
    <% control Children %>
    ...
    <% end_control %>
    <% end_if %>

    3408 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.