Extra Field IMAGE not showing in Latest_items category

  • 13 August 2015
  • 1 reply
  • 0 views

Badge

I'm working for hours for just a small code. I still don't understand why it does not work, or better, why the image are not showing.

I have the latest k2 version. (Joomla 3)

As you can see, in the item page, you will see there "Additional Info". Well, i want to add this in Latest_items category.

This is the code in item.php (Additional Info)

 

<div class="itemExtraFields">
<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?> <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span> <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>

 

If i place this in Latest_items.php, what I get is all in text.16288i87E7CE48DBA7959D.png

That's because the span

So, what i did is nothing hard, just replaced the span to img:

 

<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
<div class="matches_logo_li">
<h4>-</h4>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="
<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<img class="itemExtraFieldsValue" src="
<?php echo $extraField->value; ?>">
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php if(isset($extrafields[4]) === true):?>
<li>
<span class="itemExtraFieldsValue" >
<?php echo $extraField->value; ?>
</span>
</li>
<?php endif; ?>
</div>
<?php endif; ?>

This is what i want:

11480i9DDCD9E316207617.png

 

 

But it's just not right to work with id and img, i need more fields and i can't add every time a new id field php code and the itemExtraFieldsLabel, name of extra field, is also not showing.

If i place a new field, just a textfield like the date 14/08/2015 then its show as a image that can't be founded and thats right because i changed the tag to IMG.

But since I've added an id code of the field, can say that its working.

 

    <?php if(isset($extrafields[4]) === true):?>
<li>
<span class="itemExtraFieldsValue" >
<?php echo $extraField->value; ?>
</span>
</li>
<?php endif; ?>

 

But as I said, I can not work with id.

Someone need to help my with this. I think itsn't hard but i can not do this and it is strange that the image is not showing as span tag as it works in item.php.

 

My whole code don't want to show without this code and i really don't know why:

 

<!--
<?php $extra = json_decode($item->extra_fields); ?>
<?php if (isset($this->item->extra_fields)) : ?>
<div class="catItemExtraFields">
<ul>
<?php if (is_string($this->item->extra_fields)) {
$this->item->extra_fields = json_decode($this->item->extra_fields);
}
foreach ($this->item->extra_fields as $key=>$extraField) {
if ($extraField->value != '') {
echo "<li>".$extraField->name.": ".$extraField->value."</li>";
}
}
?>
</ul>
</div>
<?php endif; ?> -->

 

Someone help my please?

 

Regards!


1 reply

Userlevel 1
Badge +8

Hi Pcwolf

 

This is the K2 blackpearl and smartforms forum, you need to find a Joomla forum for this questions.

Reply