Keyword

Getting only extraFields Dropdown ID (not Value) in tag.php

  • Yannick Lämmel
  • Yannick Lämmel's Avatar Topic Author
  • Offline
  • New Member
More
5 years 6 months ago #169596 by Yannick Lämmel
Hi there,

before the K2 2.9 Update i was able to get extraField-Values like this (dropdowns):

$item->extraFields->Ort->value

After the 2.9 Update, im not getting a normal Array with all Values but this:
["extra_fields"]=>
string(890) "[{"id":"3","value":["5"]},{"id":"33","value":["7"]},{"id":"31","value":["2"]},..................

I managed to build a Array i could work with:

$extrafields = json_decode($item->extra_fields, true);
$extrafields = array_combine(array_column($extrafields,'id'),$extrafields);

But since it only gives me the ID of the Dropdown Option (not the Value itself), i cant work with it.
The Values are visible in extra_fields_search, but they are not ordered or anything.

How can i access the Dropdown Values?

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #169597 by JoomlaWorks
Dropdowns are meant to be used in the backend only. In the frontend you always get a label/value pair where the value is the selected option from a dropdown IN the backend.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Yannick Lämmel
  • Yannick Lämmel's Avatar Topic Author
  • Offline
  • New Member
More
5 years 6 months ago #169635 by Yannick Lämmel
Thanks for the Answer!

I dont want to use the Dropdown-Function in Frontend, I just want the selected Value in Frontend. But it gives me only it's ID..

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #169647 by JoomlaWorks
Can you paste your entire foreach loop please? Also see the above in case you want to retrieve a single extra field anywhere in your overrides:

=== Call specific extra fields in K2 templates ===
So how would you directly output individual extra fields in your K2 overrides? Simple. Just do something like this (e.g. in item.php) to get the extra field name:

$this->item->extraFields->EXTRAFIELD_ALIAS_HERE->name

To get the extra field value you would simply do this:

$this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value
$this->item->extraFields->EXTRAFIELD_ALIAS_HERE->rawValue (for date type only)

Simply replace EXTRAFIELD_ALIAS_HERE with the actual alias of the extra field you wish to output.

In modules, use:

$item->extraFields->EXTRAFIELD_ALIAS_HERE->value
$item->extraFields->EXTRAFIELD_ALIAS_HERE->rawValue (for date type only)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Yannick Lämmel
  • Yannick Lämmel's Avatar Topic Author
  • Offline
  • New Member
More
5 years 6 months ago #169658 by Yannick Lämmel
Hi,

you dont unterstand the Problem, i'll try to explain better:

I dont get the "extraFields" Array like in item.php. I need the selected Value from Field 28. The selected Value i need has (example) ID 6, and its "hotels". But it only gives me "6" as Value.
Attachments:

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #169663 by JoomlaWorks
Extra fields are processed before they are sent to be displayed.

What K2 view/task are you trying to display the extra fields?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Yannick Lämmel
  • Yannick Lämmel's Avatar Topic Author
  • Offline
  • New Member
More
5 years 6 months ago #169699 by Yannick Lämmel
I have this Problem in the Tag overview (tag.php).

Please Log in or Create an account to join the conversation.

  • Yannick Lämmel
  • Yannick Lämmel's Avatar Topic Author
  • Offline
  • New Member
More
5 years 6 months ago #169723 by Yannick Lämmel
Hello Fotis,

I really need help in this Topic. I cant access the chosen Extra-Field Values.

please look after this Problem!

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #169759 by JoomlaWorks
Everything works just fine on my end. I can't replicate your issue. Make sure the related option for extra fields is enabled in the first tab of the K2 Settings. If that doesn't work, try setting a test site with K2 to replicate the issue.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Yannick Lämmel
  • Yannick Lämmel's Avatar Topic Author
  • Offline
  • New Member
More
5 years 5 months ago #169878 by Yannick Lämmel
Thanks for the hint, the Option was deactivated..

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum