Label on page list
3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: September 17, 2013 (RSS)
By Djulia - September 16, 2013
Hi,
Which is the best approach to obtain the label of a field in the page lists?
$RECORD['test:label'] does not function.
Is it necessary to use the data of shema?
Thanks!
Djulia
By Jason - September 16, 2013
Hi Djulia,
Yes, if you want to get the field labels as they appear in the CMS, you need to load in information from the schema. To do this you can use the getSchemaFields() function. You pass into this the tableName of the section you want to load. This function returns an multi-dimensional array where the name of the field (ie, num) is the index. Inside each field in the array, there is a field called "label" with the actual field label (ie, "Record Number")
So, if you wanted to output every field name and label in a section, you could do it like this:
<?php $schemaFields = getSchemaFields("news"); ?>
<?php foreach ($schemaFields as $fieldName => $fieldInfo): ?>
<p>Field Name: <?php echo $fieldName;?></p>
<p>Field Label: <?php echo $fieldInfo['label'];?></p>
<br/>
<?php endforeach ?>
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/