Format a list field's display

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 30, 2012   (RSS)

Re: [windingoak] Format a list field's display

Hi Steve,

When a section is returned using the getRecords function the items in it will be tab separated. An array is also returned that contains all of the labels from the list. So if you had a list field called 'dropList' you could list its contents using something like this:

list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'loadUploads' => true,
'allowSearch' => false,
));
$newsRecord = @$newsRecords[0]; // get first record

//Will print out the tab seperated list
showme($newsRecord['droplist']);

//Will print out the array of labels from dropList
showme($newsRecord['[droplist:labels']);

//Print as a comma separated labels from droplist.
echo implode(', ', $newsRecord['droplist:labels']);


Thanks!
Greg Thomas







PHP Programmer - interactivetools.com