Hello,
We are developing a website based on k2. For this we make use of the extrafields to give an article an specific css class.
But when we use the archive extension this class is not applied and we get an error.
This is the error we get
Below you will see the code
We are developing a website based on k2. For this we make use of the extrafields to give an article an specific css class.
But when we use the archive extension this class is not applied and we get an error.
This is the error we get
Warning: Invalid argument supplied for foreach() in /home/recall/domains/domain.com/public_html/templates/mytemplate/html/com_k2/generic.php on line 19
Below you will see the code
<!-- START: Call to prepare extra fields -->
<?php
//convertArray to use ids as key
$extrafields = array();
foreach($this->item->extra_fields as $item)
{
$extrafields[$item->id] = $item->value;
}
?>
<!-- END: Call to prepare extra fields -->
<!-- Start K2 Generic (search/date) Layout -->
<div id="k2Container" class="genericView<?php echo $this->escape($this->params->get('page-id')); ?> nieuwsarchief">
<?php if($this->params->get('genericFeedIcon',1)): ?>
<!-- RSS feed icon -->
<ul class="k2SendReceiveNews">
<li class="legende_bestuur"><span>Bestuur</span></li>
<li class="legende_regio"><span>Regio</span></li>
<li class="legende_school"><span>School</span></li>
<li><a href="#">Nieuws melden</a></li>
<li><a href="#">Nieuws via e-mail ontvangen</a></li>
<li class="rssfeed"><a href="<?php echo $this->feed; ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_RSS'); ?>">
<span><?php echo JText::_('K2_SUBSCRIBE_TO_RSS'); ?></span>
</a></li>
<div class="clr"></div>
</ul>
<?php endif; ?>
<?php if($this->params->get('show_page_title')): ?>
<!-- Page title -->
<div class="componentheading<?php echo $this->params->get('pageclass_sfx')?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>
<?php if(count($this->items)): ?>
<div>
<?php foreach($this->items as $item): ?>
<!-- Start K2 Item Layout -->
<div class="CatItem-<?php echo $extraFlds['Nieuwscategorie']; ?>">
<?php
echo $item->extra_fields[11]->value;
?>
<div class="catItemContent catItemHeader">
<?php if($this->params->get('genericItemTitle')): ?>
<!-- Item title -->
<h3 class="catItemTitle">
<?php if ($this->params->get('genericItemTitleLinked')): ?>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else: ?>
<?php echo $item->title; ?>
<?php endif; ?>
</h3>
<?php endif; ?>
<?php if($this->params->get('genericItemDateCreated')): ?>
<!-- Date created -->
<span class="genericItemDateCreated">
<?php echo JHTML::_('date', $item->created , JText::_('DATE_FORMAT_LC10')); ?>
</span>
<?php endif; ?>
</div>
</div>
<!-- End K2 Item Layout -->
<?php endforeach; ?>
</div>
<!-- Pagination -->
<?php if($this->pagination->getPagesLinks()): ?>
<div class="k2Pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
<?php echo $this->pagination->getPagesCounter(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<!-- End K2 Generic (search/date) Layout -->