Plugin/Events/Content: Difference between revisions
From Joomla! Documentation
Update alternative link |
m removed Category:Specifications using HotCat |
||
| (One intermediate revision by the same user not shown) | |||
| Line 142: | Line 142: | ||
*<tt>components/com_users/models/login.php</tt> | *<tt>components/com_users/models/login.php</tt> | ||
*<tt>plugins/user/profile/profile.php</tt> | *<tt>plugins/user/profile/profile.php</tt> | ||
<noinclude> | <noinclude> </noinclude> | ||
Latest revision as of 13:07, 10 June 2013
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
articleA reference to the article that is being rendered by the view.paramsA reference to an associative array of relevant parameters. The view determines what it considers to be relevant and passes that information along.limitstartAn 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.
articleThe article that is being rendered by the view.paramsAn associative array of relevant parameters.limitstartAn 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.
articleThe article that is being rendered by the view.paramsAn associative array of relevant parameters.limitstartAn 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.
articleThe article that is being rendered by the view.paramsAn associative array of relevant parameters.limitstartAn 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
articleA reference to the JTableContent object that is being saved which holds the article data.isNewA 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
articleA reference to the JTableContent object that is being saved which holds the article data.isNewA 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
contextThe 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.dataAn object containing the data for the form.
Return Value
booleanTrue 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
formThe JForm object to be displayed. Use the $form->getName() method to check whether this is the form you want to work with.dataAn object containing the data for the form.
Return Value
booleanTrue 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