eworkers / K2ForJ4

GNU General Public License v2.0
11 stars 6 forks source link

Calling individual extrafields do not work #41

Closed krmrtrzv closed 8 months ago

krmrtrzv commented 9 months ago

In K2 / J3 it was possible to call individual extra-fields by name or alias, like: <?php if($this->item->extraFields->MyExtraFirldName->name): ?> <?php echo $this->item->extraFields->MyExtraFirldName->value; ?>. This functionality seems not working in J4 or there is a new way for the call?

eworkers commented 8 months ago

share you code please so we can take a look, this API has not been changed. note that to get the extra-field name: $this->item->extraFields->EXTRAFIELD_ALIAS->name; note this EXTRAFIELD_ALIAS, it is not YourExtraFirldName, it is your YourExtraFieldAlias and to get the the value of it: $this->item->extraFields->EXTRAFIELD_ALIAS->value;

krmrtrzv commented 8 months ago

Thanks so much! In the meantime I discovered another way of calling individual extra fields. Here is my code:

<?php if ($this->item->params->get('itemExtraFields') && isset($this->item->extra_fields) && count($this->item->extra_fields)): ?>

            <ul>
            <?php foreach ($this->item->extra_fields as $key =>

$extraField): ?> <?php if ($extraField->value != ''): ?> <?php if ($extraField->name == 'MyExtraFieldName'): ?>

  • value; ?>
  •                 <?php endif; ?>

    ... <?php endif; ?> <?php endforeach; ?> <?php endif; ?>

    It works perfectly, Please close this issue and enormous thank you for your contribution!

    On Fri, 12 Jan 2024 at 09:14, eworkers @.***> wrote:

    share you code please so we can take a look, this API has not been changed. note that to get the extra-field name: $this->item->extraFields->EXTRAFIELD_ALIAS->name; note this EXTRAFIELD_ALIAS, it is not YourExtraFirldName, it is your YourExtraFieldAlias and to get the the value of it: $this->item->extraFields->EXTRAFIELD_ALIAS->value;

    — Reply to this email directly, view it on GitHub https://github.com/eworkers/K2ForJ4/issues/41#issuecomment-1888547324, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE5GULRYETMOBUGY376AOTYODPEHAVCNFSM6AAAAABA4PSDMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBYGU2DOMZSGQ . You are receiving this because you authored the thread.Message ID: @.***>