Skip to content

Instantly share code, notes, and snippets.

@rkmaier
Created February 12, 2013 13:37
Show Gist options
  • Save rkmaier/4769929 to your computer and use it in GitHub Desktop.
Save rkmaier/4769929 to your computer and use it in GitHub Desktop.
Joomla 2.5/3.0 Plugin template
<?php
/**
* @package {{PACKAGE}}
* @subpackage {{SUBPACKAGE}}
* @copyright Copyright (C) 2013 {{COPYRIGHT}}. All rights reserved.
* @license GNU General Public License version 2 or later when included with or used in the Joomla CMS.
*/
// No direct access.
defined('_JEXEC') or die;
/**
* Example content plugin for display gists.
*
* @package {{PACKAGE}}
* @subpackage {{SUBPACKAGE}}
* @since 1.0
*/
class PlgContentContent extends JPlugin
{
/**
* Listener for the 'onContentAfterDelete' event.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $context The context of the content passed to the plugin.
* @param object $article A JTableContent object
*
* @return void
*
* @since 1.0
*/
public function onContentAfterDelete($context, $article)
{
}
/**
* Listener for the 'onContentAfterDisplay' event.
*
* This event is triggered by the view. The results are imploded and displayed in a placeholder.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $context The context for the content passed to the plugin.
* @param object $article The content object. Note $article->text is also available.
* @param object $params The content parameters.
* @param integer $page The 'page' number.
*
* @return string
*
* @since 1.0
*/
public function onContentAfterDisplay($context, $article, $params, $page = 0)
{
return '';
}
/**
* Listener for the 'onContentAfterSave' event.
*
* This event is triggered immediately after content is saved in the data source.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $context The context of the content passed to the plugin.
* @param object $article A JTableContent object
* @param boolean $isNew If the content has just been created
*
* @return void
*
* @since 1.0
*/
public function onContentAfterSave($context, $article, $isNew)
{
}
/**
* Listener for the 'onContentPrepare' event.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $context The context for the content passed to the plugin.
* @param object $article The content object. Note $article->text is also available.
* @param object $params The content parameters.
* @param integer $page The 'page' number (zero is the first page).
*
* @return boolean True is successful, false some problem occurred.
*
* @since 1.0
*/
public function onContentPrepare($context, $article, $params, $page = 0)
{
// Don't run this plugin when the content is being indexed.
if ($context == 'com_finder.indexer')
{
return true;
}
// Insert code here.
return true;
}
/**
* Listener for the 'onContentPrepareForm' event.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
*
* @since 1.0
*/
public function onContentPrepareForm($form, $data)
{
return true;
}
/**
* Listener for the 'onCategoryChangeState' event.
*
* This event is triggered immediately after content is saved in the data source.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $extension The context of the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 1.0
*/
public function onCategoryChangeState($extension, $pks, $value)
{
}
/**
* Listener for the 'onContentBeforeSave' event.
*
* This event is triggered immediately before content is saved in the data source,
* so any changes make to $article will be stored.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $context The context of the content passed to the plugin.
* @param object $article A JTableContent object
* @param boolean $isNew If the content has just been created
*
* @return void
*
* @since 1.0
*/
public function onContentBeforeSave($context, $article, $isNew)
{
}
/**
* Listener for the 'onContentChangeState' event.
*
* This event is triggered when content is published, unpublished, archived, or unarchived from a list view.
*
* DESCRIBE WHAT THIS METHOD DOES
*
* @param string $context The context of the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 1.0
*/
public function onContentChangeState($context, $pks, $value)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment