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.

Template Questions

Iterate through all fields of one record


2 Posts   856 Views


19 November 2010 at 1:40am (Last edited: 19 November 2010 1:41am), Community Member, 7 Posts

Hi all,

I'd like to iterate through all the fields of a single record in an SS template. As a simple example, I'm trying to automatically output all the fields of a Member record.


function MemberData() {
return Member::CurrentUser();

<% control MemberData %>
<% control Children %>
$key: $value
<% end_control %>
<% end_control %>

I've tried various permutations of returning DataObject, GetIterator(), ArrayData(), DataObject::database_fields, DataObjectSet, but I'm unable to find any way to iterate through the fields as Children (or otherwise)...

Would very much appreciate some extra brains on this one... any guidance?


19 November 2010 at 2:52am Forum Moderator, 1796 Posts

how about...


function MemberFields() {
   return Member::CurrentUser()->getCMSFields();

<% control MemberFields %>
   $Title $Value
<% end_control %>

(note untested)