Minifrontpagepro Layout Override and add fields

I tried to add fields to the newsy.php file, but without success.

example 1
<?php
if (isset($fields->value) && !empty($fields->value)) : ?>
<?php echo $fields->label; ?>
<?php echo $fields->value; ?>
<?php  endif; ?>

example 2
<?php echo $fields->value; ?>

example 3
<?php echo $fields->value; ?>
    
 
2 months 5 days ago #1 by dejanbojovic
The topic has been locked.
  • Posted by TemplatePlazza (4849) Offline
Hi, Can you tell me in more detail about what result you are trying to get?
2 months 5 days ago #2 by TemplatePlazza
The topic has been locked.
I need to place the extra field in certain places. I used minifrontpagepro for k2 and joomla 3 using this code:
<?php if(isset($item->extraFields->cena->value) === true  && empty($item->extraFields->cena->value) === false): ?>
<!-- here you can add the code you like to be shown -->
<div class="cena-default"><p><?php echo $item->extraFields->cena->value;?>€</p></div>
<!-- End Code -->
<?php endif; ?>

Now I would like to do the same in joomla 4

using this code for Minitek slider:
<?php $item->jcfields = Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields('com_content.article', $item, true);
$fields = [];
 
 foreach ($item->jcfields as $jcfield)
{
  $fields[$jcfield->name] = $jcfield;
}
?>
<div class="kategorija-objekta-cat"><?php echo $fields['kategorija']->value; ?></div>

but it doesn't work in minifrontpagepro.









 
2 months 3 days ago #3 by dejanbojovic
Attachments:
The topic has been locked.
  • Posted by TemplatePlazza (4849) Offline
Hi, both the codes you mentioned are different. One for K2 and one for Joomla com_content. Can you explain it in more detail?
Also, are you trying to run K2 in Joomla 4?
2 months 3 days ago #4 by TemplatePlazza
The topic has been locked.
I just gave you an example of how it worked with k2.

I don't use k2 anymore because it doesn't support joomla 4.

Now I use joomla 4 content.

I simply need code to display a specific field. As shown in the attached image.
2 months 2 days ago #5 by dejanbojovic
Attachments:
The topic has been locked.
  • Posted by TemplatePlazza (4849) Offline
You can do something like this :
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);
foreach((array)$item->jcfields as $jcfield) {
echo $jcfield->label;
echo $jcfield->value;
}
2 months 1 day ago - 2 months 1 day ago #6 by TemplatePlazza
Last edit: 2 months 1 day ago by TemplatePlazza.
The topic has been locked.
Powered by Kunena Forum