- Posts: 14
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Getting only extraFields Dropdown ID (not Value) in tag.php
Getting only extraFields Dropdown ID (not Value) in tag.php
- Yannick Lämmel
- Topic Author
- Offline
- New Member
Less
More
6 years 1 month ago #169596
by Yannick Lämmel
Getting only extraFields Dropdown ID (not Value) in tag.php was created 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?
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.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 1 month ago #169597
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on 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.
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
6 years 1 month ago #169635
by Yannick Lämmel
Replied by Yannick Lämmel on 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..
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.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 1 month ago #169647
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on 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)
=== 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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
6 years 1 month ago #169658
by Yannick Lämmel
Replied by Yannick Lämmel on 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.
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.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 1 month ago #169663
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on 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?
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
6 years 1 month ago #169699
by Yannick Lämmel
Replied by Yannick Lämmel on 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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
6 years 1 month ago #169723
by Yannick Lämmel
Replied by Yannick Lämmel on 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!
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.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 1 month ago #169759
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on 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.
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
6 years 1 month ago #169878
by Yannick Lämmel
Replied by Yannick Lämmel on 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.
- Forum
- K2 Community Forum
- English K2 Community
- Getting only extraFields Dropdown ID (not Value) in tag.php