Actions

J1.5

Difference between revisions of "Plugin/Events/Content"

From Joomla! Documentation

< J1.5:Plugin/Events
(5.5.1 Overview)
(onContentPrepareData)
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[Category:Development]]
+
{{incomplete}}
[[Category:Plugins]]
+
{{RightTOC}}
====5.5 Content Events for Plugin System====
+
Content events are triggered during the content creation process. This may occur in views in the com_content component, or in other components or modules.  
===5.5.1 Overview===
+
Content events are triggered during the content creation process. This may occur  
+
in views in the com_content component, or in other components or modules.  
+
  
Note: This article does not yet describe the events onBeforeContentSave and onAfterContentSave that were added in [http://www.joomla.org/content/view/5180/1/1/1/#Content_Trigger_Additions Joomla 1.5.4]
+
==onPrepareContent==
 
+
===Description===
===5.5.2 onBeforeDisplay===
+
==5.5.2.1 Description==
+
This event is triggered when the framework is ready to create content. When this event
+
triggers, all features that can affect the presentation format are loaded.
+
==5.5.2.2 Parameters==
+
None.
+
==5.5.2.3 Return Value==
+
None.
+
==5.5.2.4 Used in files==
+
  *index.php
+
  *administrator/index.php
+
  *components/com_content/views/article/view.html.php
+
  *components/com_content/views/category/view.html.php
+
  *components/com_content/views/frontpage/view.html.php
+
  *components/com_content/views/section/view.html.php
+
  *modules/mod_newsflash/helper.php
+
  *plugins/content/pagenavigation.php
+
  *plugins/content/vote.php
+
 
+
===5.5.3 onAfterDisplay===
+
==5.5.3.1 Description==
+
This event is triggered when the framework has finished creating content.
+
==5.5.3.2 Parameters==
+
None.
+
==5.5.3.3 Return Value==
+
None.
+
==5.5.3.4 Used in files==
+
  *index.php
+
  *administrator/index.php
+
  *components/com_content/views/article/view.html.php
+
  *components/com_content/views/category/view.html.php
+
  *components/com_content/views/frontpage/view.html.php
+
  *components/com_content/views/section/view.html.php
+
  *modules/mod_newsflash/helper.php
+
 
+
===5.5.4 onPrepareContent===
+
==5.5.4.1 Description==
+
 
This is the first stage in preparing content for output and is the most common point  
 
This is the first stage in preparing content for output and is the most common point  
 
for content orientated plugins to do their work. Since the article and related parameters  
 
for content orientated plugins to do their work. Since the article and related parameters  
 
are passed by reference, event handlers can modify them prior to display.
 
are passed by reference, event handlers can modify them prior to display.
==5.5.4.2 Parameters==
+
===Parameters===
  *article A reference to the article that is being rendered by the view.
+
*<code>article</code> A reference to the article that is being rendered by the view.
  *params A reference to an associative array of relevant parameters. The view determines what it considers to be relevant and passes that information along.
+
*<code>params<code> A reference to an associative array of relevant parameters. The view determines what it considers to be relevant and passes that information along.
  *limitstart An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.
+
*<code>limitstart</code> An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.
==5.5.4.3 Return Value==
+
===Return Value===
 
None. Results are returned by modifying the referenced arguments.
 
None. Results are returned by modifying the referenced arguments.
==5.5.4.4 Used in files==
+
===Used in files===
  *components/com_content/views/article/view.html.php
+
*<tt>components/com_content/views/article/view.html.php</tt>
  *components/com_content/views/article/view.pdf.php
+
*<tt>components/com_content/views/article/view.pdf.php</tt>
  *components/com_content/views/category/view.html.php
+
*<tt>components/com_content/views/category/view.html.php</tt>
  *components/com_content/views/frontpage/view.html.php
+
*<tt>components/com_content/views/frontpage/view.html.php</tt>
  *components/com_content/views/section/view.html.php
+
*<tt>components/com_content/views/section/view.html.php</tt>
  *plugins/content/code.php
+
*<tt>plugins/content/code.php</tt>
  *plugins/content/emailcloak.php
+
*<tt>plugins/content/emailcloak.php</tt>
  *plugins/content/geshi.php
+
*<tt>plugins/content/geshi.php</tt>
  *plugins/content/image.php
+
*<tt>plugins/content/image.php</tt>
  *plugins/content/loadmodule.php
+
*<tt>plugins/content/loadmodule.php</tt>
  *plugins/content/pagebreak.php
+
*<tt>plugins/content/pagebreak.php</tt>
  *plugins/content/sef.php
+
*<tt>plugins/content/sef.php</tt>
  
===5.5.5 onAfterDisplayTitle===
+
==onAfterDisplayTitle==
==5.5.5.1 Description==
+
===Description===
 
This is a request for information that should be placed between the content title and  
 
This is a request for information that should be placed between the content title and  
 
the content body.
 
the content body.
==5.5.5.2 Parameters==
+
Although parameters are passed by reference, this is not the event to modify article data. Use onPrepareContent for that purpose.
See the onPrepareContent event for additional discussion of these parameters. Note that
+
===Parameters===
unlike onPrepareContent, these parameters are passed by value.
+
See the onPrepareContent event for additional discussion of these parameters.
  *article The article that is being rendered by the view.
+
*<code>article</code> The article that is being rendered by the view.
  *params An associative array of relevant parameters.
+
*<code>params</code> An associative array of relevant parameters.
  *limitstart An integer that determines the "page" of the content that is to be generated.
+
*<code>limitstart</code> An integer that determines the "page" of the content that is to be generated.
==5.5.5.3 Return Value==
+
===Return Value===
An array. In XHTML/HTML views, this is is an array of strings, each of which becomes a line in the output stream.
+
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.
==5.5.5.4 Used in files==
+
===Used in files===
  *components/com_content/views/article/view.html.php
+
*<tt>components/com_content/views/article/view.html.php</tt>
  *components/com_content/views/category/view.html.php
+
*<tt>components/com_content/views/category/view.html.php</tt>
  *components/com_content/views/frontpage/view.html.php
+
*<tt>components/com_content/views/frontpage/view.html.php</tt>
  *components/com_content/views/section/view.html.php
+
*<tt>components/com_content/views/section/view.html.php</tt>
  *modules/mod_newsflash/helper.php
+
*<tt>modules/mod_newsflash/helper.php</tt>
==5.5.5.5 See Also==
+
===See Also===
  *components/com_content/views/article/tmpl/default.php
+
*<tt>components/com_content/views/article/tmpl/default.php</tt>
  
===5.5.6 onBeforeDisplayContent===
+
==onBeforeDisplayContent==
==5.5.6.1 Description==
+
===Description===
 
This is a request for information that should be placed immediately before the generated content. For views that generate XHTML/HTML, this might include the use of styles that are specified as part of the content or related parameters.
 
This is a request for information that should be placed immediately before the generated content. For views that generate XHTML/HTML, this might include the use of styles that are specified as part of the content or related parameters.
==5.5.6.2 Parameters==
+
Although parameters are passed by reference, this is not the event to modify article data. Use onPrepareContent for that purpose.
 +
===Parameters===
 
See the onPrepareContent event for additional discussion of these parameters. Note that  
 
See the onPrepareContent event for additional discussion of these parameters. Note that  
 
unlike onPrepareContent, these parameters are passed by value.
 
unlike onPrepareContent, these parameters are passed by value.
  *article The article that is being rendered by the view.
+
*<code>article</code> The article that is being rendered by the view.
  *params An associative array of relevant parameters.
+
*<code>params</code> An associative array of relevant parameters.
  *limitstart An integer that determines the "page" of the content that is to be generated.
+
*<code>limitstart</code> An integer that determines the "page" of the content that is to be generated.
==5.5.6.3 Return Value==
+
===Return Value===
An array. In XHTML/HTML views, this is is an array of strings, each of which becomes a line in the output stream.
+
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.
==5.5.6.4 Used in files==
+
===Used in files===
  *components/com_content/views/article/view.html.php
+
*<tt>components/com_content/views/article/view.html.php</tt>
  *components/com_content/views/category/view.html.php
+
*<tt>components/com_content/views/category/view.html.php</tt>
  *components/com_content/views/frontpage/view.html.php
+
*<tt>components/com_content/views/frontpage/view.html.php</tt>
  *components/com_content/views/section/view.html.php
+
*<tt>components/com_content/views/section/view.html.php</tt>
  *modules/mod_newsflash/helper.php
+
*<tt>modules/mod_newsflash/helper.php</tt>
==5.5.6.5 See Also==
+
  *components/com_content/views/article/tmpl/default.php
+
  
===5.5.7 onAfterDisplayContent===
+
===See Also===
==5.5.7.1 Description==
+
*<tt>components/com_content/views/article/tmpl/default.php</tt>
 +
 
 +
==onAfterDisplayContent==
 +
===Description===
 
This is a request for information that should be placed immediately after the generated content. For views that generate XHTML/HTML, this might include the closure of styles that are specified as part of the content or related parameters.
 
This is a request for information that should be placed immediately after the generated content. For views that generate XHTML/HTML, this might include the closure of styles that are specified as part of the content or related parameters.
==5.5.7.2 Parameters==
+
Although parameters are passed by reference, this is not the event to modify article data. Use onPrepareContent for that purpose.
 +
===Parameters===
 
See the onPrepareContent event for additional discussion of these parameters. Note that unlike onPrepareContent, these parameters are passed by value.
 
See the onPrepareContent event for additional discussion of these parameters. Note that unlike onPrepareContent, these parameters are passed by value.
  *article The article that is being rendered by the view.
+
*<code>article</code> The article that is being rendered by the view.
  *params An associative array of relevant parameters.
+
*<code>params</code> An associative array of relevant parameters.
  *limitstart An integer that determines the "page" of the content that is to be generated.
+
*<code>limitstart</code> An integer that determines the "page" of the content that is to be generated.
==5.5.7.3 Return Value==
+
===Return Value===
An array. In XHTML/HTML views, this is is an array of strings, each of which becomes a line in the output stream.
+
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.
==5.5.7.4 Used in files==
+
===Used in files===
  *components/com_content/views/article/view.html.php
+
*<tt>components/com_content/views/article/view.html.php</tt>
  *components/com_content/views/category/view.html.php
+
*<tt>components/com_content/views/category/view.html.php</tt>
  *components/com_content/views/frontpage/view.html.php
+
*<tt>components/com_content/views/frontpage/view.html.php</tt>
  *components/com_content/views/section/view.html.php
+
*<tt>components/com_content/views/section/view.html.php</tt>
==5.5.7.5 See Also==
+
===See Also===
  *components/com_content/views/article/tmpl/default.php
+
*<tt>components/com_content/views/article/tmpl/default.php</tt>
 +
 
 +
==onBeforeContentSave==
 +
===Description===
 +
This is an event that is called right before the content is saved into the database. Since the article object is passed by reference, you can make any changes you wish to the data. You can also abort the save by returning false. In this case the error set by calling $article->setError($message); will be displayed to user.
 +
===Parameters===
 +
*<code>article</code> A reference to the JTableContent object that is being saved which holds the article data.
 +
*<code>isNew</code> A boolean which is set to true if the content is about to be created.
 +
===Return Value===
 +
Boolean. Result will affect the saving process. See description for details.
 +
===Used in files===
 +
*<tt>administrator/components/com_content/controller.php</tt>
 +
*<tt>components/com_content/models/article.php</tt>
 +
 
 +
==onAfterContentSave==
 +
===Description===
 +
This is an event that is called after the content is saved into the database. Even though article object is passed by reference, changes will not be saved since storing data into database phase is past. An example use case would be redirecting user to the appropriate place after saving.
 +
===Parameters===
 +
*<code>article</code> A reference to the JTableContent object that is being saved which holds the article data.
 +
*<code>isNew</code> A boolean which is set to true if the content is about to be created.
 +
===Return Value===
 +
None. Result will be omitted.
 +
===Used in files===
 +
*<tt>administrator/components/com_content/controller.php</tt>
 +
*<tt>components/com_content/models/article.php</tt>
 +
 
 +
==onContentPrepareData==
 +
===Description===
 +
Called after the data for a JForm has been retrieved. It can be used to modify the data for a JForm object in memory before rendering.
 +
===Parameters===
 +
*<code>context</code> The context where this event was triggered (for example, 'com_users.profile'). Use this to check whether you are in the desired context for the plugin.
 +
*<code>data</code> An object containing the data for the form.
 +
===Return Value===
 +
*<code>boolean<code> True if method succeeds.
 +
===Used in files===
 +
*<tt>administrator/components/com_admin/models/profile.php</tt>
 +
*<tt>administrator/components/com_users/models/user.php</tt>
 +
*<tt>components/com_contact/models/contact.php</tt>
 +
*<tt>components/com_users/models/profile.php</tt>
 +
*<tt>plugins/user/profile/profile.php</tt>
 +
 
 +
==onContentPrepareForm==
 +
===Description===
 +
Called before a JForm is rendered. It can be used to modify the JForm object in memory before rendering. For example, use JForm->loadFile() to add fields or JForm->removeField() to remove fields. Or use JForm->setFieldAttribute() or other JForm methods to modify fields for the form.
 +
===Parameters===
 +
*<code>form</code> The JForm object to be displayed. Use the $form->getName() method to check whether this is the form you want to work with.
 +
*<code>data</code> An object containing the data for the form.
 +
===Return Value===
 +
*<code>boolean<code> True if method succeeds.
 +
===Used in files===
 +
*<tt>components/com_contact/models/contact.php</tt>
 +
*<tt>libraries/joomla/application/component/modelform.php</tt>
 +
*<tt>components/com_users/models/login.php</tt>
 +
*<tt>plugins/user/profile/profile.php</tt>
 +
<noinclude>[[Category:Plugin Development]][[Category:Specifications]]</noinclude>

Revision as of 14:24, 20 October 2011

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Quill icon.png
Content is Incomplete

This article or section is incomplete, which means it may be lacking information. You are welcome to assist in its completion by editing it as well. If this article or section has not been edited in several days, please consider helping complete the content.
This article was last edited by Dextercowley (talk| contribs) 2 years ago. (Purge)

Contents

Content events are triggered during the content creation process. This may occur in views in the com_content component, or in other components or modules.

onPrepareContent

Description

This is the first stage in preparing content for output and is the most common point for content orientated plugins to do their work. Since the article and related parameters are passed by reference, event handlers can modify them prior to display.

Parameters

  • article A reference to the article that is being rendered by the view.
  • params A reference to an associative array of relevant parameters. The view determines what it considers to be relevant and passes that information along.
  • limitstart An integer that determines the "page" of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.

Return Value

None. Results are returned by modifying the referenced arguments.

Used in files

  • components/com_content/views/article/view.html.php
  • components/com_content/views/article/view.pdf.php
  • components/com_content/views/category/view.html.php
  • components/com_content/views/frontpage/view.html.php
  • components/com_content/views/section/view.html.php
  • plugins/content/code.php
  • plugins/content/emailcloak.php
  • plugins/content/geshi.php
  • plugins/content/image.php
  • plugins/content/loadmodule.php
  • plugins/content/pagebreak.php
  • plugins/content/sef.php

onAfterDisplayTitle

Description

This is a request for information that should be placed between the content title and the content body. Although parameters are passed by reference, this is not the event to modify article data. Use onPrepareContent for that purpose.

Parameters

See the onPrepareContent event for additional discussion of these parameters.

  • article The article that is being rendered by the view.
  • params An associative array of relevant parameters.
  • limitstart An integer that determines the "page" of the content that is to be generated.

Return Value

String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.

Used in files

  • components/com_content/views/article/view.html.php
  • components/com_content/views/category/view.html.php
  • components/com_content/views/frontpage/view.html.php
  • components/com_content/views/section/view.html.php
  • modules/mod_newsflash/helper.php

See Also

  • components/com_content/views/article/tmpl/default.php

onBeforeDisplayContent

Description

This is a request for information that should be placed immediately before the generated content. For views that generate XHTML/HTML, this might include the use of styles that are specified as part of the content or related parameters. Although parameters are passed by reference, this is not the event to modify article data. Use onPrepareContent for that purpose.

Parameters

See the onPrepareContent event for additional discussion of these parameters. Note that unlike onPrepareContent, these parameters are passed by value.

  • article The article that is being rendered by the view.
  • params An associative array of relevant parameters.
  • limitstart An integer that determines the "page" of the content that is to be generated.

Return Value

String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.

Used in files

  • components/com_content/views/article/view.html.php
  • components/com_content/views/category/view.html.php
  • components/com_content/views/frontpage/view.html.php
  • components/com_content/views/section/view.html.php
  • modules/mod_newsflash/helper.php

See Also

  • components/com_content/views/article/tmpl/default.php

onAfterDisplayContent

Description

This is a request for information that should be placed immediately after the generated content. For views that generate XHTML/HTML, this might include the closure of styles that are specified as part of the content or related parameters. Although parameters are passed by reference, this is not the event to modify article data. Use onPrepareContent for that purpose.

Parameters

See the onPrepareContent event for additional discussion of these parameters. Note that unlike onPrepareContent, these parameters are passed by value.

  • article The article that is being rendered by the view.
  • params An associative array of relevant parameters.
  • limitstart An integer that determines the "page" of the content that is to be generated.

Return Value

String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.

Used in files

  • components/com_content/views/article/view.html.php
  • components/com_content/views/category/view.html.php
  • components/com_content/views/frontpage/view.html.php
  • components/com_content/views/section/view.html.php

See Also

  • components/com_content/views/article/tmpl/default.php

onBeforeContentSave

Description

This is an event that is called right before the content is saved into the database. Since the article object is passed by reference, you can make any changes you wish to the data. You can also abort the save by returning false. In this case the error set by calling $article->setError($message); will be displayed to user.

Parameters

  • article A reference to the JTableContent object that is being saved which holds the article data.
  • isNew A boolean which is set to true if the content is about to be created.

Return Value

Boolean. Result will affect the saving process. See description for details.

Used in files

  • administrator/components/com_content/controller.php
  • components/com_content/models/article.php

onAfterContentSave

Description

This is an event that is called after the content is saved into the database. Even though article object is passed by reference, changes will not be saved since storing data into database phase is past. An example use case would be redirecting user to the appropriate place after saving.

Parameters

  • article A reference to the JTableContent object that is being saved which holds the article data.
  • isNew A boolean which is set to true if the content is about to be created.

Return Value

None. Result will be omitted.

Used in files

  • administrator/components/com_content/controller.php
  • components/com_content/models/article.php

onContentPrepareData

Description

Called after the data for a JForm has been retrieved. It can be used to modify the data for a JForm object in memory before rendering.

Parameters

  • context The context where this event was triggered (for example, 'com_users.profile'). Use this to check whether you are in the desired context for the plugin.
  • data An object containing the data for the form.

Return Value

  • boolean True if method succeeds.

Used in files

  • administrator/components/com_admin/models/profile.php
  • administrator/components/com_users/models/user.php
  • components/com_contact/models/contact.php
  • components/com_users/models/profile.php
  • plugins/user/profile/profile.php

onContentPrepareForm

Description

Called before a JForm is rendered. It can be used to modify the JForm object in memory before rendering. For example, use JForm->loadFile() to add fields or JForm->removeField() to remove fields. Or use JForm->setFieldAttribute() or other JForm methods to modify fields for the form.

Parameters

  • form The JForm object to be displayed. Use the $form->getName() method to check whether this is the form you want to work with.
  • data An object containing the data for the form.

Return Value

  • boolean True if method succeeds.

Used in files

  • components/com_contact/models/contact.php
  • libraries/joomla/application/component/modelform.php
  • components/com_users/models/login.php
  • plugins/user/profile/profile.php