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

Data Relationship Tutorial Question


Go to End


2 Posts   679 Views

Avatar
SilverstripeNewbie

Community Member, 14 Posts

27 September 2015 at 11:47pm

In the tutorial listed below, Why is $Students and $Mentors accessible in ProjectsHolder.ss?

https://docs.silverstripe.org/en/3.1/tutorials/dataobject_relationship_management/

<% include SideBar %>
<div class="content-container unit size3of4 lastUnit">
<article>
<h1>$Title</h1>
<div class="content">
$Content
<table>
<thead>
<tr>
<th>Project</th>
<th>Students</th>
<th>Mentors</th>
</tr>
</thead>
<tbody>
<% loop $Children %>
<tr>
<td>
<a href="$Link">$Title</a>
</td>
<td>
<% loop $Students %>
$Name ($University)<% if $Last !=1 %>,<% end_if %>
<% end_loop %>
</td>
<td>
<% loop $Mentors %>
$Name<% if $Last !=1 %>,<% end_if %>
<% end_loop %>
</td>
</tr>
<% end_loop %>
</tbody>
</table>
</div>
</article>
</div>

Avatar
swaiba

Forum Moderator, 1899 Posts

28 September 2015 at 8:18pm

Because the context shifts to the object within each loop, so the Mentor is available while in the Student context.