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.

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   1481 Views

Avatar
ck_bullet

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.

Avatar
ck_bullet

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 http://example.com/pagetype_a, but if someone went to http://example.com/pagetype_a/pagetype_b they would get the page not found template. But, if they went to http://example.com/pagetype_a/pagetype_b/pagetype_c they would get the "C" template.

Avatar
Devlin

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 %>