- Moves the item in a given category
- Moves it into trash
- Deletes it permanently
- Unpublishes it
The categories to work from can be set up using the plugin parameters.
Now I wanted to change this behavior and use K2 extra field value as criteria for manipulating K2 item's state.
Extra field data is written inside k2_items table in extra_field column like this:
[{"id":"12","value":"18"},{"id":"16","value":"2013-01-28"},{"id":"13","value":""},{"id":"14","value":""}]
I want to perform action based on value of the id:16.
So I started buy putting this code in content plugin file:
$db = JFactory::getDBO();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT extra_fields FROM #__k2_items WHERE catid IN ({$sourcecat}) AND published = 1 AND trash = 0";
$db->setQuery($query);
$dateExtraFields = $db->loadObjectList();
dump($dateExtraFields);
$sourcecat is list of category id's to work with and is found in plugin parameters, I access this data with this line:
$sourcecat = trim($pluginparams->def('sourcecat'));
I'm trying to dump $dateExtraFields variable with J!Dump component.
And as result I get array, but it's displayed 6 times as you can see in these screenshots:
I don't know why is that happening, any suggestions?