为什么可以在 ProjectsHolder.ss 中访问 $Students 和 $Mentors?
Why is $Students and $Mentors accessible in ProjectsHolder.ss?
在下面列出的教程中,为什么可以在 ProjectsHolder.ss 中访问 $Students 和 $Mentors?
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>
ProjectsHolder.ss
模板使用以下循环代码遍历子 Project
页面:
<% loop $Children %>
...
<% end_loop %>
在该循环内,代码在每个 Project
页面的范围内,因此它会调用 Project
.
上的变量和函数
由于 Project
具有 Mentors
和 Students
关系,因此可以在该循环中调用它们。
在下面列出的教程中,为什么可以在 ProjectsHolder.ss 中访问 $Students 和 $Mentors?
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>
ProjectsHolder.ss
模板使用以下循环代码遍历子 Project
页面:
<% loop $Children %>
...
<% end_loop %>
在该循环内,代码在每个 Project
页面的范围内,因此它会调用 Project
.
由于 Project
具有 Mentors
和 Students
关系,因此可以在该循环中调用它们。