InMotion Hosting Support Center
This is archived and no longer maintained. Any information contained in this article may be out of date.

Joomla 2.5 has reached its end of life as for 12/31/2014. Please be advised this may be a security risk to your website. You can view more information about the end of life here.

In our last article, we covered the various events at which content plugins can be triggered. For example, we looked at both onContentPrepare and onContentAfterTitle. You may have noticed that when each plugin is triggered, it is passed the following variables:

  • com_content.article
  • &$item
  • &$this->params
  • $offset
$results = $dispatcher->trigger('onContentPrepare', array ('com_content.article', &$item, &$this->params, $offset));

In this content plugin tutorial, we will look at each of these variables more closey and examine what they include.

When looking at Joomla's Pagebreak plugin's php file, you can see an example of how the functions are written to handle these variables. For example, to access com_content.article, the $context variable would be used.

public function onContentPrepare($context, &$row, &$params, $page = 0)


com_content.article / $context

There's not much to look at with com_content.article, it helps define the context of what is triggering the function. For example, if $context = com_content.article, you know that you're code is being called within an article.


&$item / &$row

$row is an object and contains the content of the article and other information about it. For example, it will include the id of the article, the title and alias, and much more. You can view all of the items in the $row object by printing it to the screen using the following code:

public function onContentPrepare($context, &$row, &$params, $page = 0)
    echo "<pre>"; print_r($row); echo "</pre>";

As you can see in the screenshot below, there is a ton of information about the article stored in this object!



&$this->params / &$params

The params object contains obviously the paramters of the article. For example, the following are all considered article paramters:

  • show_title
  • show_intro
  • show_hits

To see all of the values within the $params object, you can print the variable to the screen using the following code:

public function onContentPrepare($context, &$row, &$params, $page = 0)
    echo "<pre>"; print_r($params); echo "</pre>";


$offset / $page = 0

If you're using Page Breaks to split up an article, the $page variable will tell you which page you're on. By default, $page will be 0. When somone is on the second page of the article, $page will have a value of 1, and so on.

Joomla Community Google+ Hangout #3

June 3rd, 2014

Thank you @RustyJoomla for letting me speak on the Joomla Community Google+ Hangout!

Click here to watch!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!