Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » question to DataObject

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 857 Views
  • marcink
    Community Member
    89 Posts

    question to DataObject Link to this post


    i want to modify the tutorial 5.

    now, i have a Project -> extends Page, that has a Student tab, where i can add some students. and i have a Student.php -> extends DataObject.

    each student is a Student DataObject.

    when i come to my project page, i want to display all students.

    i suppose, i need a function in Project.php that returns all the Student datafields...
    can someone show me how to write such a function?


    in the Project.Php i have:

       static $has_one = array(
          'Students' => 'Student'

    so should i use in my template:

    <% control Students %>
    ... some html
    <% end_control %>

    but this doesn't work...

  • marcink
    Community Member
    89 Posts

    Re: question to DataObject Link to this post

    so, i downloaded the sourcefiles of tutorial 5, copied them in their folders, run db/build?flush=1,
    entered some students and mentors in the project - this is working properly, but none is displayed in the published site...

    did enything changed to the tutorial 5 in ss 2.3 rc1 ??

    if you know soething that could help, let me know!


  • ChrisBryer
    Community Member
    95 Posts

    Re: question to DataObject Link to this post

    from a project holder template, you could write:

    <% control Children %>
    <% control Students %> //or <% control MyStudent %> if your variables match the tutorials code.
    <li>$FirstName $Lastname</li>
    <% end_control %>
    <% end_control %>

    this works in 2.2.3, but havent tried in 2.3rc1

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.