gbstn10 Posted February 4, 2015 Posted February 4, 2015 Does anyone know how you'd go about calling a custom field value from a database in Pages? I want to display data on a page from my database, but I have no idea on how to do it aside from using a template – which won't work in the way I need it to.
bfarber Posted February 4, 2015 Posted February 4, 2015 You are attempting to get the value of a field from a database in pages? You would do something like$recordClass = '\\IPS\\cms\\RecordsX'; // 'X' here is the database ID $record = $recordClass::load( Y ); // 'Y' here is the record you are loading print $record->customFieldDisplayByKey( 'key', 'listing' ); // 'key' is the field key and you can specify 'listing' or 'display' for the formatting you want // You can also do something like this instead $fieldsClass = '\\IPS\\cms\\RecordsX'; // 'X' here is the database ID foreach( $fieldsClass::roots() as $row ) { $field = 'field_' . $row->id; $value = $record->$field; print $row->formatForDisplay( $row->displayValue( $value ), $value, 'listing' ); }
gbstn10 Posted February 4, 2015 Author Posted February 4, 2015 Thank you for the reply. I'll see if I can get it to work
Recommended Posts
Archived
This topic is now archived and is closed to further replies.