Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Children of a Holder page won't Display.

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

Page: 1
Go to End
Author Topic: 1082 Views
  • toddmkimball
    Avatar
    Community Member
    13 Posts

    Children of a Holder page won't Display. Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Children of a Holder page won't Display. Link to this post

    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.

  • toddmkimball
    Avatar
    Community Member
    13 Posts

    Re: Children of a Holder page won't Display. Link to this post

    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

  • SSadmin
    Avatar
    Community Member
    90 Posts

    Re: Children of a Holder page won't Display. Link to this post

    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.

  • toddmkimball
    Avatar
    Community Member
    13 Posts

    Re: Children of a Holder page won't Display. Link to this post

    @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

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