Hey guys!
I've been using K2 for quite some time now and on a new website I'm building there is a small problem which is displaying certain extra fields (not all) at the search results page of Joomla. Not being able to show them by default I decided to write my own code that does the trick.
What I did is to write some code that queries the database -using the result's id- and gets all the extra fields using json decoding to display them in a readable format. My problem there, is that each item has 100 extra fields and json takes ages to decode them all when I have let's say 20 items per page. So I was wondering if there is a way to speed up the results?
Below you can see a snippet of the code to see if you can help a little:
This brings the first 16 extra fields of the item and then I decode the extra_fields column using json which has all the extra fields and their values, so I can display them at the search results page. I think I need to optimize my SQL code, so if anyone has a clue please help. I'm sure some other guys will need to do that, so I guess it will be helpful for the community.
Thanks in advance!
I've been using K2 for quite some time now and on a new website I'm building there is a small problem which is displaying certain extra fields (not all) at the search results page of Joomla. Not being able to show them by default I decided to write my own code that does the trick.
What I did is to write some code that queries the database -using the result's id- and gets all the extra fields using json decoding to display them in a readable format. My problem there, is that each item has 100 extra fields and json takes ages to decode them all when I have let's say 20 items per page. So I was wondering if there is a way to speed up the results?
Below you can see a snippet of the code to see if you can help a little:
SELECT e.id AS extra_id, e.name, e.type, i.extra_fields, g.name AS group_name FROM jos_k2_extra_fields e, jos_k2_categories c, jos_k2_items i, jos_k2_extra_fields_groups g WHERE i.catid = c.id AND g.id = c.extraFieldsGroup AND g.id = e.group AND e.published=1 AND i.id = ".$result->id." ORDER BY e.ordering ASC LIMIT 0, 16Thanks in advance!