- Posts: 15
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Module -> extrafield ->dropdown $extra->value not returning what expected
Module -> extrafield ->dropdown $extra->value not returning what expected
- roland
- Topic Author
- Offline
- New Member
Less
More
5 years 7 months ago #171603
by roland
Module -> extrafield ->dropdown $extra->value not returning what expected was created by roland
Hi,
I do not understand what I am doing wrong. I am modifying a module to retrieve K2 extra fields. I can retrieve with no issue all fields except one.
$extras = json_decode($item->extra_fields,false);
foreach($extras as $key=>$extra) {
if ($extra->id == 1) {
$level = intval($extra->value);
}
elseif ($extra->id == 3) {
$credits = intval($extra->value);
}
...
The id=3 corresponds to a drop-down selection with values:
0,1,2,3,6,9,12,18,12,27,7
Instead of returning 6 or 9 it returns a 5 or a 7.
Is there a specific way to analyze the drop-down value ?
br
Roland
I do not understand what I am doing wrong. I am modifying a module to retrieve K2 extra fields. I can retrieve with no issue all fields except one.
$extras = json_decode($item->extra_fields,false);
foreach($extras as $key=>$extra) {
if ($extra->id == 1) {
$level = intval($extra->value);
}
elseif ($extra->id == 3) {
$credits = intval($extra->value);
}
...
The id=3 corresponds to a drop-down selection with values:
0,1,2,3,6,9,12,18,12,27,7
Instead of returning 6 or 9 it returns a 5 or a 7.
Is there a specific way to analyze the drop-down value ?
br
Roland
Please Log in or Create an account to join the conversation.
- roland
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
5 years 7 months ago #171609
by roland
Replied by roland on topic Module -> extrafield ->dropdown $extra->value not returning what expected
Hi
I guess need to include a call to function getItemExtraFields
I am a bit lost on how to do this. I have downloaded the module 'ja image hotspot'. What I am coding for personal use is associating an image to an k2 item.
I retrieve a K2 item id, call the db for the item to get all fields. I get the extrafields and decode them correctly with json. Where I am stuck is to do the correspondence to get the value for an id for a 'select' type of field.
How to declare and call model for function getItemExtraFields($itemExtraFields, &$item = null)
regards
Roland
I guess need to include a call to function getItemExtraFields
I am a bit lost on how to do this. I have downloaded the module 'ja image hotspot'. What I am coding for personal use is associating an image to an k2 item.
I retrieve a K2 item id, call the db for the item to get all fields. I get the extrafields and decode them correctly with json. Where I am stuck is to do the correspondence to get the value for an id for a 'select' type of field.
How to declare and call model for function getItemExtraFields($itemExtraFields, &$item = null)
regards
Roland
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
5 years 7 months ago #171616
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Module -> extrafield ->dropdown $extra->value not returning what expected
See how we do it in mod_k2_content's helper.php file.
github.com/getk2/k2/blob/master/modules/mod_k2_content/helper.php#L371
github.com/getk2/k2/blob/master/modules/mod_k2_content/helper.php#L371
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- roland
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
5 years 7 months ago #171619
by roland
Replied by roland on topic Module -> extrafield ->dropdown $extra->value not returning what expected
Hi Fotis,
I've managed to make it work. Thanks a lot.
I think this feature I have easily implemented should be an option on the free JA Imagespot module of joomlart folks.
Feature: a dedicated field for a marker that will show the data of a K2 item id. The data of the dedicated field is simple the K2 item id.
br
Roland
I've managed to make it work. Thanks a lot.
I think this feature I have easily implemented should be an option on the free JA Imagespot module of joomlart folks.
Feature: a dedicated field for a marker that will show the data of a K2 item id. The data of the dedicated field is simple the K2 item id.
br
Roland
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
5 years 7 months ago #171629
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Module -> extrafield ->dropdown $extra->value not returning what expected
Well, you can always let them know :)
Glad you sorted it out.
Glad you sorted it out.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- Module -> extrafield ->dropdown $extra->value not returning what expected