Hi community
I'm struggling with how to find the middle of a dataset for templating purposes. I'm rendering a series of data objects loaded through a has_many relation, and I want to split a column when I've passed the middle of the set.
Since the templating language has basically no support for comparison or evaluation I've had to hack core by adding this to ViewableData:
public function PastMiddle() {
return $this->MultipleOf(ceil($this->TotalItems() / 2)) && !$this->Last();
}
Needless to say this feels wholly inappropriate, but I can't seem to find another way - I've probably missed something obvious.
Does anybody have any suggestions for how this sort of problem might be solved?