Question

How can i show a K2 extrafield in another 3d part extension? If i guess correctly, to achieve this there must be firstly a file include of any k2 file, which contains a business logic of extrafields, then the code, which converts Array to use extrafield ids as keys, and then the extrafield code. The code will look like this:

<?php
       $extrafields = array();
          foreach($this->item->extra_fields as $item)
            { $extrafields[$item->id] = $item->value;
            }
   echo $extrafields['4']; 
?>

Can somebody point me to k2 file, which must be included, or, if my guess is wrong, to correct solution? Thanks in advance! Egon

Was it helpful?

Solution

First, there is no "K2 file" that needs to be included really. What you need is to know the item ID of the K2 item that you want to get the extra fields from, then create a SQL query that gets the extra field data from that item. A simple function within your component is all that is needed. Pass the item ID to the function to pull the data.

The hard part is going to be figuring out which item to pull the data from. Somewhere in the process you have to associate the K2 items to each record in your component.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top