get_field
(Since 1.2.0) -- get a column value
This function returns a column value.
function get_field($name, $orderby = null)
Parameters
| Parameter | Type | Details |
|---|---|---|
| $name | STRING | the column name |
| $orderby | STRING | (optional) if a PICK column, how to sort the results (e.g. "name ASC") |
Returns
- PICK column: ARRAY
- PICK column single field (e.g. "person.name"): STRING
- File column: ARRAY
- File column single field (e.g. "file.guid"): STRING
- Other column types: STRING
- Returns false on error.
Examples
Using get_field() in List Pages:
<?php
$Record = new Pod('pod_name');
$Record->findRecords('id DESC', 15);
while ($Record->fetchRecord())
{
echo $Record->get_field('column_name');
echo $Record->get_field('pick_or_file_upload_name.column_name');
}
?>
Using get_field() in Detail Pages:
<?php
$item_id = 1; // You must find this ID manually!
$Record = new Pod('pod_name', $item_id);
echo $Record->get_field('column_name');
?>
Using get_field() in Pod Templates and Helpers:
<?php
echo $this->get_field('column_name');
?>
