Fields

Official documentation on using fields in your override https://docs.joomla.org/Special:MyLanguage/J3.x:Adding_custom_fields/Overrides

Note fields come out of the box in an array ordered by their order so if you're using them in a hardcoded manner like below it's often nice to reindex them by name or id prior to using them.

Using fields in an article override


// Rearrange Fields for use 
foreach($this->item->jcfields as $jcfield){
    $this->item->jcFields[$jcfield->name] = $jcfield;
}

// Use some field's raw value
if(!empty($this->item->jcFields['feature-image-display']->rawvalue)){
    echo $this->item->jcFields['feature-image-display']->rawvalue;
}

Using fields of an article in some other code


$item = (object) ['id' => $id,'catid' => 10 ];
$fields = FieldsHelper::getFields('com_content.article', $item, true);

// Rearrange Fields for use
$fields_by_id = [];
foreach($fields as $f){
    $fields_by_id[$f['id']] = $f;
}