Keyword

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

  • roland
  • roland's Avatar Topic Author
  • Offline
  • New Member
More
5 months 3 weeks ago #171603 by roland
roland created the topic: Module -> extrafield ->dropdown $extra->value not returning what expe
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 months 3 weeks ago #171609 by roland
roland replied the topic: Module -> extrafield ->dropdown $extra->value not returning what expe
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.

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
5 months 3 weeks ago #171616 by Fotis
Fotis replied the topic: Module -> extrafield ->dropdown $extra->value not returning what expe
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

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.

  • roland
  • roland's Avatar Topic Author
  • Offline
  • New Member
More
5 months 2 weeks ago #171619 by roland
roland replied the topic: Module -> extrafield ->dropdown $extra->value not returning what expe
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.

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
5 months 2 weeks ago #171629 by Fotis
Fotis replied the topic: Module -> extrafield ->dropdown $extra->value not returning what expe
Well, you can always let them know :)

Glad you sorted it out.

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.

Moderators: william white

Powered by Kunena Forum