Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Outputting a simple array


Go to End


2 Posts   1863 Views

Avatar
sarahk

Community Member, 46 Posts

12 May 2008 at 4:44pm

I have an array which is basically

$output = array('oranges','apples','lemons');

but the list will change over time and it's needed for a quick visual audit. The query is actually doing a distinct so it doesn't relate to any particular object.

In my controller I have a function called SummaryList and it can output the array.

To get that array to be accessible in my template, however the array needs to be wrapped in ArrayData but that doesn't work because the array isn't associative.

What is the best way of outputting this so that I can loop through the array and what is the right template syntax?

Avatar
sarahk

Community Member, 46 Posts

12 May 2008 at 5:06pm

Thanks to the IRC crowd I got this sorted using DataObjectSet