Answer the question
In order to leave comments, you need to log in
How to add additional fields in Joomla?
The task is to set additional fields manually.
<?php
// GET CUSTOM FIELDS
$myCustomFields = array();
foreach($this->item->jcfields as $field) {
$myCustomFields[$field->name] = $field->value;
}
// RECOVER CUSTOM FILED NAME
if (isset($myCustomFields['field-1']) and !empty($myCustomFields['field-1'])) : ?>
<div class="field">
<div class="field__name">Название поля:</div>
<div class="field__value"><?php echo $myCustomFields['field-1']; ?></div>
</div>
<?php endif; ?>
Warning: Invalid argument supplied for foreach() in C:\OpenServer\domains\center-skidok.loc\templates\centerskidok\html\com_tags\tag\default_items.php on line 65
Answer the question
In order to leave comments, you need to log in
This is not a blog category template. It is you who are trying to display the fields from the materials in the "labels" component, so they are not there.
This is how you can
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);
$fields = [];
foreach($item->jcfields as $jcfield)
{
$fields[$jcfield->name] = $jcfield;
}
$fields['имя_поля']->rawvalue;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question