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, Ed, biapar, Willr, Ingo

question to DataObject

Go to End

3 Posts   1079 Views


Community Member, 89 Posts

17 November 2008 at 3:48am

Edited: 17/11/2008 5:41am


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


Community Member, 89 Posts

17 November 2008 at 6:13am

Edited: 17/11/2008 6:13am

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!



Community Member, 95 Posts

18 November 2008 at 8:44am

Edited: 18/11/2008 8:45am

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