Hi.
I'm wondering if there's a better solution to retrieve Extrafields on K2 Backend in the items list view. The main objective is to show some quick infos about the items without have to oppening one by one. In my example, it retrieves a link and also the price for the item.
Right now, I'm using this code:
Everything works fine, BUT I have to use this workaround for check the first letters of the extrafield, since depending on the item, it might have more extrafields, and this will change the id of the extrafield retrieved (sometimes it's 0, but it can also be 1 for other articles).
The result is as shown in the attachment.
If anyone has some hint.
Thanks in advance!
I'm wondering if there's a better solution to retrieve Extrafields on K2 Backend in the items list view. The main objective is to show some quick infos about the items without have to oppening one by one. In my example, it retrieves a link and also the price for the item.
Right now, I'm using this code:
<?php $string = $row->extra_fields; $extra=json_decode($string); ?>
<?php if ($extra[2]->value): ?>
<?php if (substr($extra[1]->value, 0,5) === 'https'): ?>
<a style="border: 1px solid;padding: 5px;" href="<?php echo $extra[1]->value ?>" target="_blank"><img src="/images/amazon36.png" style="height:18px";> R$: <?php echo $extra[3]->value ?></a>
<?php endif; ?>
<?php if (substr($extra[0]->value, 0,5) === 'https'): ?>
<a style="border: 1px solid;padding: 5px;" href="<?php echo $extra[0]->value ?>" target="_blank"><img src="/images/amazon36.png" style="height:18px";> R$: <?php echo $extra[2]->value ?></a>
<?php endif; ?>
<?php endif; ?>Everything works fine, BUT I have to use this workaround for check the first letters of the extrafield, since depending on the item, it might have more extrafields, and this will change the id of the extrafield retrieved (sometimes it's 0, but it can also be 1 for other articles).
The result is as shown in the attachment.
If anyone has some hint.
Thanks in advance!