im trying to perform a conditional check to include a different template based on the total number of children. so if there is only one child, display the full entry...if there is more than 1, display a summary list.
my code looks like this:
// model //////////////////////////////////////////////////////
class ExhibitionsHolder extends Page {
...
public function numChildren(){
return DB::query("SELECT COUNT(*) FROM SiteTree_Live WHERE ParentID = '$this->ID'")->value();
}
}
// template code //////////////////////////////////////////////////////////
<% if numChildren == 1 %>
<!-- display only 1 entry -->
<% include ExhibitionPage %>
<% else %>
<% if numChildren == 0 %>
No entries found....
<% else %>
<!-- display summary of all entries -->
<% include ExhibitionList %>
<% end_if %>
<% end_if %>
this works...however, wondering if there is a better way to do this without having to nest conditional statements.
i tried using else_if...but it did not work.