【问题标题】:Silverstripe 3: How to get images from multiple pages for display on another page in a function?Silverstripe 3:如何从多个页面获取图像以显示在函数中的另一个页面上?
【发布时间】:2014-01-11 17:13:24
【问题描述】:
【问题讨论】:
标签:
image
function
silverstripe
【解决方案1】:
如果您的图库页面都是您的客户列表页面的子页面,您可以在Children 上致电loop 并检索每个ClientLogo:
ClientListPage 模板
<% loop $Children %>
$ClientLogo
<% end_loop %>
如果您的图库页面不是您的客户列表页面的所有子页面,您将需要在控制器中创建一个函数来获取所有图库页面以循环访问它们。
ClientListPage 控制器
private static $allowed_actions = array (
'GalleryPages'
);
function GalleryPages()
{
$galleryPages = GalleryPage::get();
return $galleryPages ? $galleryPages : false;
}
ClientListPage 模板
<% loop $GalleryPages %>
$ClientLogo
<% end_loop %>