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

If Page Type?


Go to End


6 Posts   8850 Views

Avatar
corkg

Community Member, 30 Posts

17 April 2009 at 1:29am

Edited: 17/04/2009 1:59am

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

Community Member, 141 Posts

17 April 2009 at 2:14am

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

Avatar
corkg

Community Member, 30 Posts

17 April 2009 at 2:22am

Edited: 17/04/2009 2:37am

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

Community Member, 598 Posts

17 April 2009 at 2:57am

Hi eorkg

You can do this:

<% if ClassName = PageType %>

Avatar
corkg

Community Member, 30 Posts

17 April 2009 at 4:43am

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

Community Member, 145 Posts

17 April 2009 at 5:56pm

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

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