Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » How to make a grandchild "act" like a child

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

Page: 1
Go to End
Author Topic: 808 Views
  • ck_bullet
    Avatar
    Community Member
    16 Posts

    How to make a grandchild "act" like a child Link to this post

    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.

  • ck_bullet
    Avatar
    Community Member
    16 Posts

    Re: How to make a grandchild "act" like a child Link to this post

    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.

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: How to make a grandchild "act" like a child Link to this post

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

    808 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.