Code: Select all
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
Code: Select all
<div class="field-1"><?php $item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);echo FieldsHelper::render('com_content.article', 'field.render', ['field'=>$item->jcfields[1]]);?></div>
<div class="field-2"><?php $item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);echo FieldsHelper::render('com_content.article', 'field.render', ['field'=>$item->jcfields[2]]);?></div>
<div class="field-3"><?php $item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);echo FieldsHelper::render('com_content.article', 'field.render', ['field'=>$item->jcfields[3]]);?></div>
Code: Select all
<?php echo $item->jcfields[n]->value; ?>
Also, I noticed that in using this route the field numbers are NOT the field IDs but rather the sequential order in which they are arranged - starting from 0 - and how they appear in the article editor fields tab, which could have disastrous consequences if I were to rearrange the fields. This is not how it works in articles, though. When manually adding fields to an article layout - i.e. not automatically displayed - and using the short code above the field IDs are used.