Data at Your Fingertips: Explore Our New Reporting and Statistical Capabilities By Ryan Ashbrook 20 hours ago
gbstn10 Posted February 4, 2015 Share 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. Link to comment Share on other sites More sharing options...
bfarber Posted February 4, 2015 Share 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' ); } Link to comment Share on other sites More sharing options...
gbstn10 Posted February 4, 2015 Author Share Posted February 4, 2015 Thank you for the reply. I'll see if I can get it to work Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.