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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to make a grandchild "act" like a child

Go to End

3 Posts   1122 Views


Community Member, 16 Posts

30 July 2010 at 10:34am

Let's say I have a page that is a top-level item named "A" that uses "class A". Then that page has a child page named "B" which uses "class B". Then "B" has a child named "C" using "class C". Page "B" doesn't have it's own template because I don't want to show anything for "B", I only use this page to group "C" items together. Ideally I want the "A" template to just display a certain amount of "C" items regardless of it's "B" parent all ordered by creation date. And then if you were to go to a "C" template, then you can also see a select group of it's siblings and also be able to navigate back to "A", it's grandfather. So "B" is only for categorizing all my "C" items, I hope what I just wrote makes sense. I'm not sure there is a better method to grouping pages of a certain type while being able to dynamically create new groups. I'm having trouble with the data model and the relationships. Any help would be greatly appreciated.


Community Member, 16 Posts

3 August 2010 at 4:56am

I think the easier solution for me would be to "hide" the "B" class from the front end. How would I do that? So "A" has the url, but if someone went to they would get the page not found template. But, if they went to they would get the "C" template.


Community Member, 344 Posts

5 August 2010 at 5:52am

Edited: 05/08/2010 6:12am

I think I would check the parent urlsegment in page b. If it is empty than display content from the 404 page.
You should also be able to call the 404 page directly, somehow.

In the navigation you could check for class b or check if it has children. If not than just display the children.
Something like:

<% control Children %>
	<% if ClassName ClassB %>
	<% else %>
		ClassB: $Link
	<% end_if %>
	<% control Children %>
		ClassC: $Link
	<% end_control %>
<% end_control %>