Hi,
I'm currently experiencing issues trying to iterate and display content from a DataList in a template. I've managed to find a way to get it to work, but it doesn't feel like the right way to do it. Here is what I've got:
Feature.php
public static function GetNumFeaturesBySection($arguments, $content = null, $parser = null, $tagName) {
$numberOfFeatures = (int)$arguments['num'];
$section = $arguments['section'];
$listOfFeatures = Feature::get()->filter(array('Section.Title' => $section))->limit(4);
return $listOfFeatures->renderWith('MultipleFeatureTemplate');
}
-------
MultipleFeatureTemplate.ss
<div class='row'>
<% loop $Me %>
<div class="col-md-4">
<h3>$Title</h3>
<p>$Description</h3>
<% end_loop %>
</div>
This code results in each Feature items getting rendered to the webpage on load, but I really don't like that
<% loop $Me %>
bit at all. I can't find any documentation on it and I only randomly stumbled upon it in this silverstripe forum question. I tried the other suggestion from the answerer in that post, but it doesn't work. Anyone out there have a better understanding on the proper way to iterate over $listOfFeatures in my template? Thanks!