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
2 months 1 day ago #169596 by Yannick Lämmel
Yannick Lämmel created the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 months 1 day ago #169597 by Fotis
Fotis replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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
1 month 4 weeks ago #169635 by Yannick Lämmel
Yannick Lämmel replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 month 4 weeks ago #169647 by Fotis
Fotis replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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)


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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
1 month 4 weeks ago #169658 by Yannick Lämmel
Yannick Lämmel replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 month 4 weeks ago #169663 by Fotis
Fotis replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
Extra fields are processed before they are sent to be displayed.

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


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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
1 month 3 weeks ago #169699 by Yannick Lämmel
Yannick Lämmel replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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
1 month 3 weeks ago #169723 by Yannick Lämmel
Yannick Lämmel replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 month 2 weeks ago #169759 by Fotis
Fotis replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
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.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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
1 month 2 weeks ago #169878 by Yannick Lämmel
Yannick Lämmel replied the topic: Getting only extraFields Dropdown ID (not Value) in tag.php
Thanks for the hint, the Option was deactivated..

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

Moderators: william white