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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Children of a Holder page won't Display.


5 Posts   1148 Views


13 April 2010 at 6:08am (Last edited: 13 April 2010 6:16am), Community Member, 13 Posts

So, I have a page type which is a container for other pages, let's call them AHolder and AChild. When viewing an AHolder page I want to list the children of that page using the following:

<% control Children %>
<h2><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></h2>
<p><strong>$Date.Nice</strong> - $Content.FirstParagraph <a href="$Link" title="Read more on &quot;{$Title}&quot;">Read more &gt;&gt;</a></p>
<% end_control %>

This, however is producing a blank page and no error messages. Any ideas?


EDIT: I forgot to mention. The children are on the third level of the site tree. So, I have:

Top Level Page
|- AHolder
|-- AChild
|-- AChild
|-- etc...


13 April 2010 at 10:11am Forum Moderator, 5511 Posts

This, however is producing a blank page and no error messages. Any ideas?

Make sure display_errors is set to on in your php.ini file so that you can get some more useful error messages. If you cannot alter this setting simply try and isolate what line is causing the error by removing code bit by bit.


13 April 2010 at 2:04pm (Last edited: 13 April 2010 2:05pm), Community Member, 13 Posts

Thanks for the reply willr. I've made the changes and still no errors. I also noticed that when I do: $Children.Count I get zero for the result. I am stumped. I've also converted the code to match the "Adding News" code from the tutorial-- same result: No children displaying and count is zero.

~ Todd


15 April 2010 at 9:59am Community Member, 90 Posts

Did you have the relationship associated with Holder and Children?
In AHolder.php

Class AHolder extends Page{
static $has_many=array('AChilds'='AChild');

Then you should be able to use the <% control Children %> loop.


15 April 2010 at 12:09pm (Last edited: 30 April 2010 4:16am), Community Member, 13 Posts

@SSAdmin: Yes, the relationships were in place. I eventually re-coded the models and controllers and all is now well and working. I don't know why, but I'm not complaining. Thanks for the quick replies and suggestions.

~ Todd