Keyword

Finding value of custom field by custom_field_id and item_id

  • Usop Wilcha
  • Usop Wilcha's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 9 months ago #163026 by Usop Wilcha
Hi K2 experts,

To search and get title of K2 item, I'm halfway until here
if ($option=="com_k2" && $view=="item") {
    $item_id = $jinput->getInt('id');
    JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
    $item = JTable::getInstance('K2Item', 'Table', array());
    $item->load($item_id);

    $title =  $item->title;
}
How can I find the value of custom field by custom_field_id and item_id ?

Thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #163035 by Krikor Boghossian
Replied by Krikor Boghossian on topic Finding value of custom field by custom_field_id and item_id
Hello there Danny,
I will need some context. Where do you want this data shown?
Custom view, template, admin view?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Usop Wilcha
  • Usop Wilcha's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 8 months ago #163067 by Usop Wilcha
This code is called at front-end model.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 8 months ago #163082 by Krikor Boghossian
Replied by Krikor Boghossian on topic Finding value of custom field by custom_field_id and item_id
Front-end model of K2, a custom extension?
If it is the same item then you don't need any of this code, you can find the value based on the field's alias.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Usop Wilcha
  • Usop Wilcha's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 8 months ago #163096 by Usop Wilcha
Not really

I'm building a directory type website

I'm embedding external form module in the K2 field, so that every items has their own form

This sample link is not built with K2, but it has the same objective that i need

Tour code form field will be the value from the custom fields, now, the problem is how to pick up the value into our form fields,

Hope i made myself a clear explanation here :)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 8 months ago #163101 by Krikor Boghossian
Replied by Krikor Boghossian on topic Finding value of custom field by custom_field_id and item_id
Still you don't need this code. It's a bit of an overkill. You can do this within the item.php file (less queries)

You can print the value of a specific field like this
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L168-L173

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Usop Wilcha
  • Usop Wilcha's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 8 months ago #163204 by Usop Wilcha
Thanks man, you're the best! :)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 8 months ago #163210 by Krikor Boghossian
Replied by Krikor Boghossian on topic Finding value of custom field by custom_field_id and item_id
Thanks Danny :)

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