Format a list field's display

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

By windingoak - October 29, 2012

I need some help figuring out how to format the content of a list field when it's displayed on a web page. Right now, it just looks like a run-on string of information without punctuation. If I could even do something as simple as get a comma or semi-colon between the items, I would be happy.

Thanks,
Steve

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

By gregThomas - October 30, 2012

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