How can I loop through an ArrayList within another ArrayList?
I tried a lot of things and was looking all over the Silverstripe sites, but somehow I can't figure out how this works.
Anybody can give me some clue?
This is what I have now:
Function inside controller:
$pages = DataObject::get("SiteTree","MATCH (Title, Content) AGAINST ('$query' IN BOOLEAN MODE)");
$searchresults = new ArrayList(array(
'pages' => $pages
));
$data['Results'] = $searchresults;
return $this->customise($data)->renderWith(array('Page_results'));
Template:
<% if Results %>
<ul id="MainSearchResults">
<% loop Results %>
<% if pages() %>
<% loop pages() %>
<li>
<a class="searchResultHeader" href="$Link">
<% if MenuTitle %>
$MenuTitle
<% else %>
$Title
<% end_if %>
</a>
<p>$Content.LimitWordCountXML</p>
<a class="readMoreLink" href="$Link" title="Lees meer over "{$Title}"">Lees meer over " {$Title}"...</a>
</li>
<% end_loop %>
<% else %>
<p>There are no results</p>
<% end_if %>
<% end_loop %>
</ul>
<% else %>
<p>Sorry, there are no results</p>
<% end_if %>