#158 Posted in ‘Econa’

Latest post by Lefteris Kavadas on Monday, 14 May 2018 12:12 EEST

Alberto Santini
 Hi I need to render the image also in tne mod_articles_category
Hw can I do?

Lefteris Kavadas
Hi,

Which kind of integration are you using? Custom field or Article images?

Regards

Alberto Santini
I'm using Custom field

I'm trying with mod_articles_latest and mod_articles_category ...

Lefteris Kavadas
Unfortunately, the core modules have not been updated yet to display the custom fields. However, you can edit the layout override and add the following code:

$item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);
foreach($item->jcfields as $field) {
    echo FieldsHelper::render('com_content.article', 'field.render', array('field'=> $field));
}


Note that you have to enter this code inside the items loop.
This code will render all custom fields of the item. If you just want to display a single custom field use the following code (again inside the items loop):

$item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);
echo FieldsHelper::render('com_content.article', 'field.render', array('field'=> $item->jcfields[X]));


Replace X with the field ID you want to render.

If you like our extension please post a review at the Joomla extensions directory.

Let us know if you need anything else.

Regards

Alberto Santini

This is my code ... but I receive "Call to a member function get() on null"

defined('_JEXEC') or die;
?>
		<?php foreach ($list as $item) : ?>
				<?php if ($params->get('link_titles') == 1) : ?>
					<h4><a class="mod-articles-category-title <?php echo $item->active; ?>" href="https://www.firecoders.com/<?php echo $item->link; ?>"><?php echo $item->title; ?></a></h4>
				<?php else : ?>
					<h4><?php echo $item->title; ?></h4>
				<?php endif; ?>

                <img class="image_intro" src="https://www.firecoders.com/<?php echo $image->src; ?>" alt="<?php echo $images->image_intro_alt; ?>" style="width: 100%" /> 

				<?php if ($item->displayDate) : ?>
					<span class="mod-articles-category-date">
						<?php echo $item->displayDate; ?>
					</span>
				<?php endif; ?>

                    <?php
                    $item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);
                    echo FieldsHelper::render('com_content.article', 'field.render', array('field'=> $item->jcfields[1]));
                    ?>

				<?php if ($params->get('show_introtext')) : ?>
					<p class="mod-articles-category-introtext">
						<?php echo $item->displayIntrotext; ?>
					</p>
				<?php endif; ?>

					<p class="uk-text-center uk-margin-small">
						<a class="uk-button uk-button-text <?php echo $item->active; ?>" href="https://www.firecoders.com/<?php echo $item->link; ?>">
							<?php if ($item->params->get('access-view') == false) : ?>
							<?php elseif ($params->get('show_readmore_title', 0) == 0) : ?>
								Continua a leggere
							<?php endif; ?>
						</a>
					</p>
         <hr class="uk-divider-icon">
    	<?php endforeach; ?>
            <a class="uk-button uk-button-text <?php echo $item->active; ?>" href="https://www.firecoders.com/index.php?option=com_content&view=category&layout=blog&id=8&Itemid=117">leggi tutte le altre news</a>

Alberto Santini


!!!!!!!! It's right ..... The custom field id is "1" ... but probably the array is 0 ...
So I've changed it and now is done!


$item->jcfields = FieldsHelper::getFields('com_content.article', $item, true);
                    echo FieldsHelper::render('com_content.article', 'field.render', array('field'=> $item->jcfields[0]));


Thank you so much!!

Lefteris Kavadas
You are welcome! Please post a review if you like our extension!

Regards

Note: An active subscription is required in order to get support for our paid extensions. For our free extensions, if you don't have an account, register and then submit your support request.  In case you just want to ask a question, you can also use the contact form .

Firecoders
Are you using our extensions? Please post a review at the Joomla extensions directory!
Post a review