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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top