Can someone help me, what is wrong with this code and why it doesn't work?
I am trying to create a plugin to cut the number of words in a similar way as the module does.
function onK2PrepareContent ( & $item, $params, $limitstart ) {
global $mainframe;
$plugin = & JPluginHelper::getPlugin('k2', 'cut');
$pluginParams = new JParameter($plugin->params);
$words = $params->get('words', 0);
$option = JRequest::getCmd('option');
$layout = JRequest::getCmd('layout');
$task = JRequest::getCmd('task');
if ($option == 'com_k2' && $layout == 'category' && $task=='category')
{
$item->text = '';
if ($params->get('words')>0) {
$item->text .= K2HelperUtilities::wordLimit($item->introtext, $params->get('words'));
}
else {
$item->text .= $item->introtext;
}
$item->introtext = $item->text;
}