Hello,
I noticed that there are some big changes for extra fields and that you can now output an extra field using -, which is great.
But I would like to display extra field values in category.php.
For example:
I'm in category with 3 items.
Each item has an extra field with value a, value b, value c
On top of category (category.php) I would like to output - value a, value b, value c.
I'm trying to create a simple sorting solution.
I tried using this code - I found it in forum
and
But it seems that either I did something wrong or this code doesn't work with newer k2 versions.
I noticed that there are some big changes for extra fields and that you can now output an extra field using -
$this->item->extraFields->EXTRAFIELDALIASHERE->valueBut I would like to display extra field values in category.php.
For example:
I'm in category with 3 items.
Each item has an extra field with value a, value b, value c
On top of category (category.php) I would like to output - value a, value b, value c.
I'm trying to create a simple sorting solution.
I tried using this code - I found it in forum
<!-- Call to prepare extra field IDs -->
<?php
//convertArray to use ids as key
$extrafieldsid = array();
foreach($this->item->extra_fields as $itemid)
{
$extrafieldsid[$itemid->id] = $itemid->value;
}
?>
<!-- Call to prepare extra field labels -->
<?php
//convertArray to use labels as key
$extrafieldslabels = array();
foreach($this->item->extra_fields as $itemlabel)
{
$extrafieldslabels[$itemlabel->id] = $itemlabel->name;
}
?>and
<!-- Extra Fields -->
<div class="extrafield">
<strong><?php echo $extrafieldslabels[1];?>: </strong><?php echo $extrafieldsid[1];?>
</div>
<div class="extrafield">
<strong><?php echo $extrafieldslabels[2];?>: </strong><?php echo $extrafieldsid[2];?>
</div>
<div class="clr"></div>
<!-- End Extra Fields -->But it seems that either I did something wrong or this code doesn't work with newer k2 versions.