Keyword

Module -> extrafield ->dropdown $extra->value not returning what expected

  • roland
  • roland's Avatar Topic Author
  • Offline
  • New Member
More
5 years 4 weeks ago #171603 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

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

  • roland
  • roland's Avatar Topic Author
  • Offline
  • New Member
More
5 years 3 weeks ago #171609 by roland
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

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

More
5 years 3 weeks ago #171616 by JoomlaWorks
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

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
  • roland's Avatar Topic Author
  • Offline
  • New Member
More
5 years 3 weeks ago #171619 by roland
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

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

More
5 years 3 weeks ago #171629 by JoomlaWorks
Well, you can always let them know :)

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.


Powered by Kunena Forum