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
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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
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
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
Hi eorkg
You can do this:
<% if ClassName = PageType %>
I dont understand how to use this.
Can you interpret this in the context of NewPageType
I dont understand how classtype fits in
Thanks
corkg, I havent tested this, but in your case, it should be:
<% if ClassName = NewPageType %>
<% control Children %>
...
<% end_control %>
<% end_if %>