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

If Page Type?


Reply

6 Posts   3820 Views

Avatar
corkg

17 April 2009 at 1:29am (Last edited: 17 April 2009 1:59am), Community Member, 30 Posts

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

Avatar
Invader_Zim

17 April 2009 at 2:14am Community Member, 141 Posts

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: [url]http://doc.silverstripe.org/doku.php?id=built-in-page-controls[/url]

Cheers,
Christian

Avatar
corkg

17 April 2009 at 2:22am (Last edited: 17 April 2009 2:37am), Community Member, 30 Posts

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

Avatar
Carbon Crayon

17 April 2009 at 2:57am Community Member, 598 Posts

Hi eorkg

You can do this:

<% if ClassName = PageType %>

Avatar
corkg

17 April 2009 at 4:43am Community Member, 30 Posts

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

Thanks

Avatar
AdamJ

17 April 2009 at 5:56pm Community Member, 145 Posts

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

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