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.

Archive

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

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

question to DataObject


Reply

3 Posts   868 Views

Avatar
marcink

17 November 2008 at 3:48am (Last edited: 17 November 2008 5:41am), Community Member, 89 Posts

hi,

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?

thanks!

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

Avatar
marcink

17 November 2008 at 6:13am (Last edited: 17 November 2008 6:13am), Community Member, 89 Posts

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!

thanks

Avatar
ChrisBryer

18 November 2008 at 8:44am (Last edited: 18 November 2008 8:45am), Community Member, 95 Posts

from a project holder template, you could write:

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

this works in 2.2.3, but havent tried in 2.3rc1