<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://docs.joomla.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;feed=atom&amp;action=history</id>
		<title>Make changes to an article automatically using a plugin - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;action=history"/>
		<updated>2013-05-22T03:32:22Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.3</generator>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;diff=13077&amp;oldid=prev</id>
		<title>Dextercowley: add information about installing the plugin</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;diff=13077&amp;oldid=prev"/>
				<updated>2009-02-06T23:16:35Z</updated>
		
		<summary type="html">&lt;p&gt;add information about installing the plugin&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:16, 6 February 2009&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 92:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 92:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The code above does that. First, we get the user. Then, if the user is in the &amp;quot;Author&amp;quot; group, we change the article's &amp;quot;state&amp;quot; to zero, meaning &amp;quot;Unpublished&amp;quot;. Notice that the method has &amp;lt;tt&amp;gt;$article&amp;lt;/tt&amp;gt; as a parameter, so its fields and methods are all available to us.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The code above does that. First, we get the user. Then, if the user is in the &amp;quot;Author&amp;quot; group, we change the article's &amp;quot;state&amp;quot; to zero, meaning &amp;quot;Unpublished&amp;quot;. Notice that the method has &amp;lt;tt&amp;gt;$article&amp;lt;/tt&amp;gt; as a parameter, so its fields and methods are all available to us.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;==Install the Plugin==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Once we have the plugin coded, we need to create a zip archive so we can install it in our Joomla! site. Here are the steps:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* Use any Zip or Gzip program to make a Zip or Gzip archive of the two files created above.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* In the back end of your Joomla! site, navigate to Extensions &amp;amp;rarr; Install / Uninstall.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* Press Browse and find your zip archive file.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* Press Upload File and Install. You should get a message indicating that the extension was installed successfully.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* Finally, navigate to Extensions &amp;amp;rarr; Plugin Manager, find the new plugin (called &amp;quot;Modify Edited Articles&amp;quot; based on the name in the XML file), and enable it.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;At this point, you should be able to test that it is working as expected.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==Add Standard Text==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==Add Standard Text==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 132:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 141:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;would change the article's Section to &amp;quot;About Joomla!&amp;quot; and Category to &amp;quot;The Project&amp;quot;. Note that you need to use the &amp;quot;id&amp;quot; fields for the Section and Category. In this example, you also might want to remove these fields from the front-end form (by using a [[How_to_override_the_output_from_the_Joomla!_core|template override]])&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;would change the article's Section to &amp;quot;About Joomla!&amp;quot; and Category to &amp;quot;The Project&amp;quot;. Note that you need to use the &amp;quot;id&amp;quot; fields for the Section and Category. In this example, you also might want to remove these fields from the front-end form (by using a [[How_to_override_the_output_from_the_Joomla!_core|template override]])&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;==Other Things We Can Do==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It is useful to understand that any of the article's fields are available here. Below is a partial list:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It is useful to understand that any of the article's fields are available here. Below is a partial list:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* title: article's title&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* title: article's title&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 144:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 154:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* metadesc: Metadata Information / Description&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* metadesc: Metadata Information / Description&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* access: 0 for public, 1 for registered, 2 for special&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* access: 0 for public, 1 for registered, 2 for special&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Also, there are other built-in events we can use for plugins. These are documented in the &amp;lt;tt&amp;gt;plugins/content/example.php&amp;lt;/tt&amp;gt; file. In addition, there are other plugin types. See the [[Developers#Plugins|plugins section of the Wiki]] for more information. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Tips and tricks]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Tips and tricks]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Tips and tricks 1.5]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Tips and tricks 1.5]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dextercowley</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;diff=13076&amp;oldid=prev</id>
		<title>Dextercowley: new tip for using plugins to make automatic changes when an article is saved.</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Make_changes_to_an_article_automatically_using_a_plugin&amp;diff=13076&amp;oldid=prev"/>
				<updated>2009-02-06T23:06:24Z</updated>
		
		<summary type="html">&lt;p&gt;new tip for using plugins to make automatic changes when an article is saved.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Overview==&lt;br /&gt;
Plugins are the simplest extensions to write. A simple plugin requires only two files. Yet plugins can be extremely handy.&lt;br /&gt;
&lt;br /&gt;
One common case for using plugins is doing some customized processing every time an article is saved. For example:&lt;br /&gt;
* Change the published state of an article.&lt;br /&gt;
* Add standard text to articles.&lt;br /&gt;
* Set the Section or Category for an article.&lt;br /&gt;
&lt;br /&gt;
Let's see how you can use a simple plugin to do these types of tasks.&lt;br /&gt;
&lt;br /&gt;
==First Plugin==&lt;br /&gt;
A simple plugin has two files. One is an XML file that tells Joomla! how to install the plugin. The other is the actual plugin PHP code.&lt;br /&gt;
&lt;br /&gt;
To make it as easy as possible for people to write plugins, Joomla! includes example plugins in every installation. In our example, we are writing a &amp;quot;content&amp;quot; plugin, since we are working with articles. So the two example files we can use as guidelines are &amp;lt;tt&amp;gt;plugins/content/example.xml&amp;lt;/tt&amp;gt; amd &amp;lt;tt&amp;gt;plugins/content/example.php&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The XML file for our example is called &amp;lt;tt&amp;gt;modifyarticle.xml&amp;lt;/tt&amp;gt;. We just copied  the file &amp;lt;tt&amp;gt;plugins/content/example.xml&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;modifyarticle.xml&amp;lt;/tt&amp;gt; and put it in a new folder outside of the Joomla! installation. (''We will use the Joomla! install program later on to add this to our Joomla! system. So for now we want to keep this separate from Joomla!.'') Then we edited it as follows:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;install version=&amp;quot;1.5&amp;quot; type=&amp;quot;plugin&amp;quot; group=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;name&amp;gt;Modify Edited Articles&amp;lt;/name&amp;gt;&lt;br /&gt;
&amp;lt;creationDate&amp;gt;January 2009&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
&amp;lt;author&amp;gt;Joomla Doc Team&amp;lt;/author&amp;gt;&lt;br /&gt;
&amp;lt;authorEmail&amp;gt;myemail@myemail.com&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
&amp;lt;authorUrl&amp;gt;http://joomlacode.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
&amp;lt;copyright&amp;gt;Copyright (c) 2009&amp;lt;/copyright&amp;gt;&lt;br /&gt;
&amp;lt;license&amp;gt;GPL&amp;lt;/license&amp;gt;&lt;br /&gt;
&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
&amp;lt;description&amp;gt;Example plugin for Joomla! wiki.&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;files&amp;gt;&lt;br /&gt;
   &amp;lt;filename plugin=&amp;quot;modifyarticle&amp;quot;&amp;gt;modifyarticle.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Next, we copy the file &amp;lt;tt&amp;gt;plugins/content/example.php&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;modifyarticle.php&amp;lt;/tt&amp;gt; and put it in the same folder outside of the Joomla! installation. Then we edit this file so it reads as follows:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.&lt;br /&gt;
 * @license		GNU/GPL, see LICENSE.php&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined( '_JEXEC' ) or die( 'Restricted access' );&lt;br /&gt;
&lt;br /&gt;
jimport( 'joomla.plugin.plugin' );&lt;br /&gt;
&lt;br /&gt;
class plgContentModifyArticle extends JPlugin&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Constructor&lt;br /&gt;
	 *&lt;br /&gt;
	 * For php4 compatability we must not use the __constructor as a constructor for plugins&lt;br /&gt;
	 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.&lt;br /&gt;
	 * This causes problems with cross-referencing necessary for the observer design pattern.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param object $subject The object to observe&lt;br /&gt;
	 * @param object $params  The object that holds the plugin parameters&lt;br /&gt;
	 * @since 1.5&lt;br /&gt;
	 */&lt;br /&gt;
	function plgContentModifyArticle ( &amp;amp;$subject, $params )&lt;br /&gt;
	{&lt;br /&gt;
		parent::__construct( $subject, $params );&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Example before save content method&lt;br /&gt;
	 *&lt;br /&gt;
	 * Method is called right before content is saved into the database.&lt;br /&gt;
	 * Article object is passed by reference, so any changes will be saved!&lt;br /&gt;
	 * NOTE:  Returning false will abort the save with an error.&lt;br /&gt;
	 * 	You can set the error by calling $article-&amp;gt;setError($message)&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param 	object		A JTableContent object&lt;br /&gt;
	 * @param 	bool		If the content is just about to be created&lt;br /&gt;
	 * @return	bool		If false, abort the save&lt;br /&gt;
	 */&lt;br /&gt;
	function onBeforeContentSave( &amp;amp;$article, $isNew )&lt;br /&gt;
	{&lt;br /&gt;
		global $mainframe;&lt;br /&gt;
		$user =&amp;amp; JFactory::getUser(); // get the user&lt;br /&gt;
		if ($user-&amp;gt;usertype == 'Author') { // unpublish if user is &amp;quot;Author&amp;quot;&lt;br /&gt;
			$article-&amp;gt;state = 0; // from dev 11:59&lt;br /&gt;
		}&lt;br /&gt;
		return true;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Notice that the &amp;lt;tt&amp;gt;example.php&amp;lt;/tt&amp;gt; file has six methods plus the constructor. These document the six possible events that you can use for plugins. In our example, we want to modify the article just before it is saved to the database. So we call our method (or function) &amp;quot;onBeforeContentSave&amp;quot;. This method name must be exactly as shown. The name is what tells Joomla! when to run our plugin.&lt;br /&gt;
&lt;br /&gt;
In standard Joomla!, when a user in the &amp;quot;Author&amp;quot; group first submits a new article, it is set to &amp;quot;Unpublished&amp;quot;. However, once the article has been published, this user can edit the article and it stays published. In our example, we want to change this so that, each time an article is edited by a user in the &amp;quot;Author&amp;quot; group, it gets changed back to &amp;quot;Unpublished&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
The code above does that. First, we get the user. Then, if the user is in the &amp;quot;Author&amp;quot; group, we change the article's &amp;quot;state&amp;quot; to zero, meaning &amp;quot;Unpublished&amp;quot;. Notice that the method has &amp;lt;tt&amp;gt;$article&amp;lt;/tt&amp;gt; as a parameter, so its fields and methods are all available to us.&lt;br /&gt;
&lt;br /&gt;
==Add Standard Text==&lt;br /&gt;
Once we have the basic framework, changing the plugin to do other things is simple. For example, say we want to add standard text to any article submitted by a user in the &amp;quot;Author&amp;quot; group. Here is the code for the &amp;quot;onBeforeContentSave()&amp;quot; method:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	function onBeforeContentSave( &amp;amp;$article, $isNew )&lt;br /&gt;
	{&lt;br /&gt;
		global $mainframe;&lt;br /&gt;
		$newText = '&amp;lt;p&amp;gt;This is my new text to add to the article.&amp;lt;/p&amp;gt;';&lt;br /&gt;
		$user =&amp;amp; JFactory::getUser(); // get the user&lt;br /&gt;
		if ($user-&amp;gt;usertype == 'Author') { &lt;br /&gt;
			if ($article-&amp;gt;fulltext) {&lt;br /&gt;
				if (strpos($article-&amp;gt;fulltext, $newText) == 0) {&lt;br /&gt;
					$article-&amp;gt;fulltext .= $newText;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			else {&lt;br /&gt;
				if (strpos($article-&amp;gt;introtext, $newText) == 0) {&lt;br /&gt;
					$article-&amp;gt;introtext .= $newText;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		return true;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In this code, we have some standard text we put in the &amp;lt;tt&amp;gt;$newText&amp;lt;/tt&amp;gt; variable. Then we deal with a complication of the &amp;lt;tt&amp;gt;$article&amp;lt;/tt&amp;gt; object. Joomla! articles can have an optional &amp;quot;Read more...&amp;quot; break. If they don't have one, the entire text of the article is in the &amp;lt;tt&amp;gt;introtext&amp;lt;/tt&amp;gt; field. If there is a &amp;quot;Read more...&amp;quot; break, then the part of the article after the break is in the &amp;lt;tt&amp;gt;fulltext&amp;lt;/tt&amp;gt; field. &lt;br /&gt;
&lt;br /&gt;
So, in the code, we have to handle both cases. If there is something in &amp;lt;tt&amp;gt;fulltext&amp;lt;/tt&amp;gt;, then we add the standard text there. Otherwise, we add it to &amp;lt;tt&amp;gt;introtext&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There is one other complication. We don't want to add the standard text if it already there. Otherwise, we would keep adding more copies of it each time the article is edited. So we test to see if it already part of the article's text and we only add it if it isn't already there.&lt;br /&gt;
&lt;br /&gt;
Notice that the second parameter of this method is &amp;lt;tt&amp;gt;$isNew&amp;lt;/tt&amp;gt;. This is a boolean that is &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if this is a new article. So we could test for that if we only wanted to add the text for new article submissions.&lt;br /&gt;
&lt;br /&gt;
==Set the Section or Category==&lt;br /&gt;
Setting the Section or Category ID of an article is very easy. For example, in the Sample Website, this code&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   $article-&amp;gt;sectionid = '4';&lt;br /&gt;
   $article-&amp;gt;catid = '25';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
would change the article's Section to &amp;quot;About Joomla!&amp;quot; and Category to &amp;quot;The Project&amp;quot;. Note that you need to use the &amp;quot;id&amp;quot; fields for the Section and Category. In this example, you also might want to remove these fields from the front-end form (by using a [[How_to_override_the_output_from_the_Joomla!_core|template override]])&lt;br /&gt;
&lt;br /&gt;
It is useful to understand that any of the article's fields are available here. Below is a partial list:&lt;br /&gt;
* title: article's title&lt;br /&gt;
* alias: article's alias&lt;br /&gt;
* state: 0 for unpublished, 1 for published, -1 for archived&lt;br /&gt;
* created: date created&lt;br /&gt;
* created_by: user id of author&lt;br /&gt;
* created_by_alias: author alias field&lt;br /&gt;
* modified: date last modified&lt;br /&gt;
* modified_by: user id of last author to modify&lt;br /&gt;
* metakey: Metadata Information / Keywords&lt;br /&gt;
* metadesc: Metadata Information / Description&lt;br /&gt;
* access: 0 for public, 1 for registered, 2 for special&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;/div&gt;</summary>
		<author><name>Dextercowley</name></author>	</entry>

	</feed>