Keyword

Plugin Development onK2PrepareContent

  • Bastian Schneider
  • Bastian Schneider's Avatar Topic Author
  • Offline
  • New Member
More
11 years 6 months ago #111560 by Bastian Schneider
Plugin Development onK2PrepareContent was created by Bastian Schneider
Hi everybody,

I´m trying to build a plugin that displays some content inline and would like to use onK2PrepareContent - but it does not work. The Code below is loaded but never comes to onK2PrepareContent function.

Can anybody help me out?

Thanks
Bastian

<?php
/**
* @version 1.0
* @package Inline Advertising (K2 plugin)
* @author Bastian Schneider - www.internet-konzepte.com
* @copyright Copyright (c) 2006 - 2012 Bastian Schneider
* @license GNU/GPL license: www.gnu.org/copyleft/gpl.html
*/

defined('_JEXEC') or die ('Restricted access');
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'k2plugin.php');

class InlineAdvertising extends K2Plugin {
var $pluginName = 'inlineads';
var $pluginNameHumanReadable = 'Inline Advertising Plugin';

function InlineAdvertising( & $subject, $params) {
parent::__construct($subject, $params);
$this->_plugin = JPluginHelper::getPlugin( 'content', 'jwsig' );
}

function onK2PrepareContent( &$item, &$params, $limitstart) {
$mainframe = &JFactory::getApplication();
$this->item->extra_fields = K2ModelItem::getItemExtraFields($this->item->extra_fields);
$extraFlds = array();
if ( $this->item->extra_fields ){
foreach ( $this->item->extra_fields as $key=>$extraField ){
$extraFlds[ $extraField->name ] = $extraField->value;
$test.=$extraField->name;
}
}
$item->text = 'It works! '.$test.$item->text;
}
} // END CLASS

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 6 months ago - 11 years 6 months ago #111561 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Plugin Development onK2PrepareContent
Try to add plgK2 before the class name
for example: plgK2InlineAdvertising

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

Please Log in or Create an account to join the conversation.

  • Bastian Schneider
  • Bastian Schneider's Avatar Topic Author
  • Offline
  • New Member
More
11 years 6 months ago #111562 by Bastian Schneider
Replied by Bastian Schneider on topic Re: Plugin Development onK2PrepareContent
Hi Mohamed,

tried that but it did not change a thing.... The function is just not executed, had an exit right on the first function line but page loaded as usual.
If i put a syntax error in the file the page crashes, so the file is loaded and executed....

Any help is really appreciated.

Thanks
Bastian

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 6 months ago #111563 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Plugin Development onK2PrepareContent
Hi,

Just make sure to add plgK2 before the function/constructor name also.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum