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.

General Questions /

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

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

Children of a Holder page won't Display.


Go to End


5 Posts   2199 Views

Avatar
toddmkimball

Community Member, 13 Posts

13 April 2010 at 6:08am

Edited: 13/04/2010 6:16am

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 %>
<li>
<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>
</li>
<% end_control %>

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

Regards,
Todd

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

Avatar
Willr

Forum Moderator, 5523 Posts

13 April 2010 at 10:11am

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.

Avatar
toddmkimball

Community Member, 13 Posts

13 April 2010 at 2:04pm

Edited: 13/04/2010 2:05pm

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

Avatar
SSadmin

Community Member, 90 Posts

15 April 2010 at 9:59am

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

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

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

Avatar
toddmkimball

Community Member, 13 Posts

15 April 2010 at 12:09pm

Edited: 30/04/2010 4:16am

@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