InMotion Hosting Support Center

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 this first article of our tutorial series on how to create a Joomla 2.5 Content plugin, we will give you the source code for our Hello World plugin. This plugin will print "Hello World!" at the beginning of every article. As we dive further into more tutorials, we'll provide more details on what all of this code means. For now we will show you how to create the plugin, how to install the plugin, and then what it does.

Step 1: Create the Plugin Files

All Joomla 2.5 plugins contain a xml file. These xml files contain information such as who wrote the plugin and when, what files should be included with the plugin, and any plugin settings that can be adjusted. The first thing you should do is copy the following text and save it as helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="content">
        <author>Brad Markle</author>
        <creationDate>June 18th, 2012</creationDate>
        <copyright>InMotion Hosting</copyright>
        <license>GNU General Public License</license>
        <description>Simple Hello World Plugin that prints "Hello World" at the beginning of every article.</description>
                <filename plugin="helloworld">helloworld.php</filename>

After creating the XML file, we now need to create our php file, which does all of the work. The following code should be saved to helloworld.php


// no direct access
defined('_JEXEC') or die;

class plgContentHelloworld extends JPlugin
    public function onContentAfterTitle($context, &$article, &$params, $limitstart)
                return "<p>Hello World!</p>";


The last file we need to create is one named index.html. You don't need to place any code in the file, you simply need to create it.

At this stage, you should have the following files:

  • helloworld.xml
  • helloworld.php
  • index.html

Compress all of these files into a zip file named

Important! Keep in mind that Linux servers are case sensitive and helloworld.php is not the same as HelloWorld.php and so forth.

Step 2: Install the Plugin

Installing this plugin is like installing any other plugin. If you need any additional help, please see our article on how to install a Joomla 2.5 plugin.

Step 3: Enable and Test your new Plugin

When you initially install the plugin, it will be disabled, so be sure to enable the plugin.

hello-world-plugin-in-actionVisit any Joomla 2.5 article, and you should see "Hello World!" printed after the title, as in the following screenshot to the right.

Because we used the onContentAfterTitle event, our "Hello World" message is being shown on the content and after the title has been printed.

hide-show-intro-textPlease Note!
In order for this particular plugin to work, one more thing must be done. Because we're using the onContentAfterTitle event, we need to set the article's Show Intro Text value to Hide:

Continued Education in Course 215: Joomla 2.5 Content Plugin Development
You are viewing Section 1: How to create a Hello World content plugin for Joomla 2.5
Section 2: How to change the name of a Joomla 2.5 Plugin
2013-09-18 10:38 pm
good article. thanks so much
i create one simple extension in my site,here:
2013-11-08 6:39 am
how can i create system plugin i am trying but it gives me error and website is not load plugin is on my local website please give me reply on
11,186 Points
2013-11-08 9:31 am
Hello arti145,
Could you clarify what specific error you are getting?
2013-11-13 12:09 pm
I followed the instructions, but it make no changes to the content. Please help.
32,948 Points
2013-11-13 2:10 pm
Hello Hassanz,

We need more information on the issue in order to help you, please. Can you please provide a URL, version and description of how to duplicate the problem you are having?

Arnel C.
2013-11-15 12:50 pm
Hello Arn,
There is no url its on local server. I am using Joomla 2.5 with no other plugin. According to this guide ( onContentAfterTitle is only available in J3.
9,968 Points
2013-11-15 1:53 pm
<a name="onContentAfterTitle"></a>
<div style="background-color: #FFF; padding-left: 10px;">Hello hassanz,

I just tested this out and it works perfectly fine in <strong>Joomla 2.5</strong>. While the <strong>onContentAfterTitle</strong> function is only available out of the box in <strong>Joomla 3.0</strong>, when you're creating the <strong>helloworld.php</strong> file mentioned in this article, you're creating that same function with this line of code:

<pre class="code_block" style="width: 555px; white-space: normal; margin-bottom: -30px;">public function onContentAfterTitle($context, &$article, &$params, $limitstart)</pre>

Make sure that you're looking at an article after using this plugin, and also make sure that you've set the <strong>Show Intro Text</strong> value to <strong>Hide</strong> otherwise the article's default intro text will override the plugins text.

- Jacob</div>
2013-11-15 2:27 pm
okay, but even if you get it to work how do you expect one to edit 100s of article and change SHOWintroTEXT to hide ? I did not find any Global option for that.
9,968 Points
2013-11-15 3:32 pm
<div style="background-color: #FFF; padding-left: 10px;">Hello hassanz,

Thie tutorial simply covers how to create a Hello World plugin for Joomla so that you understand how Joomla plugins work.

You can also simply set this option globally if you'd like as well, by going to <strong>Content &gt; Article Manager</strong> and then clicking on <strong>Options</strong>. Then simply select <strong>Hide</strong> beside the <strong>Show Intro Text</strong> option:

<img src="" alt="joomla global show intro text">

- Jacob</div>
2013-11-15 5:44 pm
ok make sense. I have another question. How can you prevent showing "Hello World" on category page (a page where multiple article's snippet exists. But instead it should appear only when user is viewing Single Article only.
23,602 Points
2013-11-18 12:43 pm
Hello hassanz,

You can choose, which pages to assign a module to in the Admin Dashboard:
  1. Login to the Dashboard.

  2. Roll your mouse over Extensions, and click Module Manager.

  3. Click the Module you want to assign to pages.

  4. In the Menu Assignment field, choose Only on the pages selected, then you can Select the pages you want to assign the plugin/module to

  5. Click Save when you are finished.

If you have any further questions, feel free to post them below.
Thank you,

n/a Points
2015-08-13 5:38 am


Accidentally I updated updated my template.

I now cannot not get the site displaying as expected. It is trancated with menues misplaced downwords instead of across. How do I revert back? I had not done a backup.



23,602 Points
2015-08-13 12:38 pm
Hello Tabitha,

Thank you for contacting us. Have you tried changing your Joomla Site Template? For example change to a different template, that has not been updated.

Thank you,
2013-11-18 12:52 pm
plugin we created above does not appear in Module Manager.
9,968 Points
2013-11-18 2:53 pm
<div style="background-color: #FFF; padding-left: 10px;">Hello hassanz,

Sorry for the confusion, as this is a <strong>Plugin</strong> and not a <strong>Module</strong> it would instead be found in <strong>Extensions &gt; Plug-in Manager</strong>. However this plugin does not have the option to only display on single <strong>Article</strong> pages only.

Again this plugin was not intended for actual real world use, but rather demonstrating how the Joomla plugin system works. For a more in-depth look about Joomla Plugins you'd want to check out the official <a href="" target="_blank">Joomla Plugin Development</a> page for help.

- Jacob</div>
2013-11-18 2:59 pm
Hi JacobMH,
Thanks for taking time and answering my question. I understand that it was not meant for production use but I am now in middle of creating a production plugin using the basic concept of this tutorial. (That is why I am keep coming back here for help). Unfortunately, the link you gave me is useless. I know that it is official Dev docs by Joomla but it does not cover everything. If you can guide me or point me to right direction I might be able to figure it out myself. You are more responsive than any other Joomla website I have found so far. Thanks again for all the help.
5,399 Points
2013-11-18 3:18 pm
Hi hassanz,

It looks like you've posted several questions, but your current question is how you can prevent this plugin from showing on categories?

We may need a screenshot for further help with understanding what exactly is happening, but I'll try to help first without any additional information.

<h3>Within your code, determine if you're looking at an article</h3>Within your code, you can ask Joomla to tell you whether you are looking at an article or a category. You can then use that information to enable / disable the plugin.

The following code has been tested with Joomla 3.0 and a module, but it may work with Joomla 2.5 and a plugin. The following code will create variables that tell you what component and view are currently being used:

<pre class='cli'>$option = JRequest::getVar('option');
$view = JRequest::getVar('view');</pre>

<h3>If you're not looking at an article, return nothing so the plugin does nothing</h3>When you know what option and view you're in, you should be able to use logic to return and change nothing if NOT in an article:

<pre class='cli'>// if this page is not an article<br />if($option != "com_content" AND $view != "article")<br /> return</pre>

I hope that helps! Keep us updated, hopefully we should be able to get this sorted out for you.
2013-11-18 3:32 pm
Thank you so much BradM, this works :) Now how was I supposed to find this on Joomla Docs ?
So getVar('view') says article on article page and returns category name on category page.
9,968 Points
2013-11-18 5:41 pm
<div style="background-color: #FFF; padding-left: 10px;">Hello hassanz,

I'm glad Brad's code that he shared with you was able to work in your case, the reason I shared the Joomla development documentation is because it sounds like you're interested in learning to develop with Joomla, and without a deeper understanding of how things work within Joomla it can be difficult to get things to work the way you'd like.

The way that Brad instructed for you to do this should work, but it's actually already built-in to the <strong>onContentAfterTitle</strong> function with the <strong>$context</strong> variable as well if you just wanted to use that. This information was found in the Joomla Plugin Development pages for <a href="" target="_blank">creating a content plugin</a>.

If you re-did your <strong>helloworld.php</strong> script to simply be this:

<pre class="cli" style="line-height: .7;">class plgContentHelloworld extends JPlugin
public function onContentAfterTitle(<strong style="color: red;">$context</strong>, &$article, &$params, $limitstart)
if (<strong style="color: red;">$context</strong> == "com_content.category")
return "&lt;p&gt;Hello World!&lt;/p&gt;";

It would have the exact same behavior, as it's checking first if the <strong>$context</strong> variable is <strong>com_content.category</strong> or a category page, and if it is it will return nothing. But if it doesn't detect that you're on a category page, it will go ahead and print out the <strong>Hello World!</strong> text.

Please let us know if you had any other questions.

- Jacob</div>
2013-11-20 11:00 am
Thank You, that is some good explanation. Problem is with Joomla docs, its pretty concise rather than throwing more details. I'll keep you guys posted if I get questions. Thanks again.
9,968 Points
2013-11-20 12:11 pm
<div style="background-color: #FFF; padding-left: 10px;">No problem hassanz, let us know if you run into any further snags.

- Jacob</div>
n/a Points
2014-03-20 7:46 am

how can make simple module...???


11,186 Points
2014-03-20 8:31 am
Hello Vishit,

We do not have an article on makring a simple module, but there is a <a href="">guide on creating a simple module</a> in Joomla's documentation.
n/a Points
2014-03-27 12:23 am

Hi, thanks for the sample plugin.

But i have a problem : i installed and actived plugin successfull but not display anything, i try to replace "return" to "echo" so "Hello World!" display on top of title . Please help! Thanks.

11,186 Points
2014-03-27 8:01 am
We have tested this code to ensure that it does work on Joomla 2.5. Be sure that you are running Joomla 2.5 and not another version as well as check the error logs on the server for any possible errors.

If you're still having trouble, you may send an email to with your Joomla credentials and we will be happy to take a look for you. Be sure to reply to this comment if you send us an email.
n/a Points
2014-03-27 12:37 pm

I know why, because i using joomla 2.5 but "onContentAfterTitle" function only avalible on joomla 3.x.

I just start using joomla, i want to learn how to develop a plugin and found this site.. Thanks for sharing!

9,968 Points
2014-03-27 12:53 pm
<div style="background-color: #FFF; padding-left: 10px;">Hello Sang,

You're right that the <strong>onContentAfterTitle</strong> function does not exist in Joomla 2.5 by default. If you're following the steps of this guide, you actually are creating that function for Joomla 2.5 to use.

You might want to take a look at my earlier comment about <a href="#onContentAfterTitle">creating the onContentAfterTitle function</a>, and the next few comments after that, as they explain a bit more than the guide itself about this.

Let us know if you had any other questions!

- Jacob</div>
n/a Points
2014-05-28 7:05 am

I am using joomla 3.1 but still Hello world not showing up

I  followed all the steps 

Please Help

11,186 Points
2014-05-28 7:59 am
Be sure that you have placed the entire code mentioned in the above article into the appropriate files. Once all of this has been checked over, ensure that your plugin is active, as well as the intro text is disabled as described within the article.
n/a Points
2014-07-30 6:20 am

At the time of plugin active i got this message so how can I over come it ?


The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

11,186 Points
2014-07-30 9:12 am
Could you clarify what other plugins you have currently active on your Joomla site?
n/a Points
2014-07-30 9:28 am

For the wordpress site 

23,602 Points
2014-07-30 9:49 am
Hello Shailendra,

Thank you for your question. The headers already sent message is a common Wordpress error the Wordpress codex explains is "usually because there are spaces, new lines, or other garbage before an opening tag, typically in wp-config.php."

See the full cause and solution to the headers already sent problem in the Official WordPress documentation.

If you have any further questions, feel free to post them below.
Thank you,

5,399 Points
2014-07-30 9:44 am
Hi Shailendra,

Generally you get a <strong>headers already sent</strong> error when there is a space at the end of a php file.

If the error tells you the exact file in question, look for the <strong>?&gt;</strong> at the end of the php file and make sure there is not a space after it.
n/a Points
2014-08-27 3:43 am

I couldn't get this working either. (Joomla 3.3.3.) The plugin installed fine, I activated it but get nothing. Also endure that "show intro text" was set to hide on an article. Not sure what else to check - any ideas?

Contents of the XML/PHP files below.

<?php// no direct accessdefined('_JEXEC') or die;class plgContentHelloworld extends JPlugin{    public function onContentAfterTitle($context, &$article, &$params, $limitstart)        {                return "<p>Hello World!</p>";        }}?>

<?xml version="1.0" encoding="utf-8"?><extension version="3.3" type="plugin" group="content">        <name>plg_content_helloworld</name>        <version>1.0</version>        <description>Simple Hello World Plugin that prints "Hello World" at the beginning of every article.</description>        <files>                <filename plugin="helloworld">helloworld.php</filename>                <filename>index.html</filename>        </files></extension>


37,753 Points
2014-08-27 10:50 am
Hello DaveD,

Are you getting any error message? Have you checked the error log in the files to see what type of error is occurring? Once you discover it, please reply with the full error message so we can take a look for you.

Kindest Regards,
Scott M
n/a Points
2015-05-17 3:14 pm

I have created and installed plugin. But it does not work. I don't see Hello world. (

37,753 Points
2015-05-18 3:53 pm
Alex, did you get any error messages?

n/a Points
2015-05-19 7:04 am

I don't see any error messages. I've just torn on all of error messages on hosting.

My web-site is here

32,948 Points
2015-05-20 3:17 pm

We'd need to see more information on the error in order to figure out what's happening. Can you provide the specific code from the file? And also the correct URL. The URL you provided ( jumps to the Joomla page.

Please provide this information and we can look into the issue further.

Arnel C.
n/a Points
2015-08-05 5:50 am

please help me

Fatal error: Cannot redeclare class plgContentHelloworld in C:\xampp\htdocs\f33\plugins\content\helloworld\helloworld.php on line 12


32,948 Points
2015-08-05 8:09 pm
Hello Ravi,

Sorry for the error that you're seeing. We unfortunately do not support coding issues like this one. Also, this is a non-server related issue (since you're using Xampp). You would be better supporter looking for the Xampp community. We do try to point you in the right direction as well. Check out this postg for further information.

Arnel C.
n/a Points
2015-08-11 7:45 am

helloworld not display in my home page,

i was tried more ,

please provide help...

10,077 Points
2015-08-12 12:09 am
Hello Mathesh,

Did you follow the directions exactly? Are you getting any errors on your home page when you try to call the helloworld plugin? What version of Joomla are you using?

Best Regards,
TJ Edens
n/a Points
2015-08-13 8:08 am

hi TJEdens

no error displaying in home page, joomla 3.4

23,602 Points
2015-08-13 12:44 pm
Hello Mathesh,

Thank you for contacting us. Since the above guide is written for Joomla 2.5, and some of the "event names" have changed.

I recommend following the official Joomla 3 guide on Creating a Plugin for Joomla. It includes updated information for Joomla 3.

Thank you,
n/a Points
2015-08-14 2:56 am

Hello john,

thanks for your reply,

in the administrator page only displays that helloworld ,

but in the website page not displaying ,

i changed settings show intro text->hide, but no use , article only displaying john....

32,948 Points
2015-08-14 8:59 am
Hello Mathesh,

Sorry about the problems with the plugin. We can't troubleshoot without knowing exactly what you've done in your code. Can you please provide us more information about the exact steps you have done so that we might try to duplicate the problem you're having? Can you provide the URL or more information on your account (if you're hosting with InMotion Hosting)?

Provide us more specific information on the problem and we can try to look into it further.

If you have any further questions or comments, please let us know.

Arnel C.
n/a Points
2015-08-25 12:44 am

Hi Arn,

Thanks for your reply,

sorry for delay conversation

I installed the helloworld plugin, after i enabled in administrator page, but it not display in the site , after the title, this was the problem,

i followed the all steps in tutorial part

10,077 Points
2015-08-25 9:17 pm
Hello Mathesh,

What version of Joomla are you trying to make this plugin on? Keep in mind this article is for 2.5 and 3.x is almost completely different.

Best Regards,
TJ Edens
n/a Points
2015-08-31 7:58 am

hi ,

joomla version is 3.4


37,753 Points
2015-08-31 1:33 pm
Hello Mathesh,

This article is not for your version. I am not sure how it works for yours as we do not have a current article for it. You may want to consult the official Joomla documentation and see if that helps.

Kindest Regards,
Scott M
n/a Points
2015-11-25 9:07 am

I am having the same problem and while trying to find an answer I came to this post and also found a lead

I havent tested it yet, but seems the problem lies in language file

n/a Points
2015-11-25 10:20 pm


I got mine to work and figure out somethings that were not well explained in the joomla documentation it self.

In my case the problem did lied in the plugin name, so I will write here what I expeienced and my undertanding of the beast.

The Joomla docs show examples of plugin names like

User - Hello World

Content - Hello World

The problem in my case was that I could not name the plugin like that, instead I had to name it plg_hello_world and then if I wanted to show a pretty name like the above I needed to create a language constant with the pretty name as value and load my plugin.

I am guessing the reason for the plugin not working if you don't name it like plg_group_name might be because somewhere in the framework something like(put on a simplistic way)

$plgname = explode("_","plg_group_name");

foreach( $plgname as $partname){

echo ucfirst($partname);


This would echo the plugin name just like the class plgGroupName.

While if we name our plugin Content - Hello World and the framework try to make sense of that, it will never match the class pattern.

So in my case and in my opnion it is very importat we follow the correct name structure

Please feel free to correct me if I am saying something worng here.

Post a Comment

Email Address:
Phone Number:

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

54 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!