View more context



I would probably do the splitting / grouping in PHP so that you are only requesting the raw data from Database once (As I am assuming you will be displaying all items within an accordian that is grouped).

I did something similar a few weeks ago but had to add additional information to the grouping so essentially had to loop results and create my own GroupedList manually.

NOTE: yield can be useful in helping to manage memory with this.


GroupedList caveat: that'll be a lot of PHP side processing.


Is it possible to use PHP functions in a .ss file? I'm rendering a view file and passing an array of data but want to check whether certain values exist within the array before displaying a section in that view file. I thought using in_array() or isset() would be sufficient but it's behaving like the function isn't being run.


@taoceanz the way around this is to put the logic where it best belongs - this is likely your controller (assuming a page, eg. PageController), but could also be a model, etc. e.g.

  1. public function getThingExists($list) {
  2. return $list->filter('Key', $thing)->exists();

That's a really bad example (code design wise), but hopefully conveys the idea.


Ok thanks @nightjarnz that's what I had thought was going to be the next step. The original purpose was to pass an array containing values from a shortcode to an includes file to specify which sections of that includes file would display without having to create a data object to store the individual sections.

But ok, I was just being lazy and trying to make it work an easy way. Thanks for the heads up. I'll create the datatype, generate the loopable object in the controller and pass that to the view to be rendered. Will make content admin easier in the future too.