Jump to content

Database fields in Pages


Recommended Posts

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

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


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...