Simplest plugin won't work

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
Pirs01
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Sep 10, 2014 11:52 pm

Simplest plugin won't work

Post by Pirs01 » Tue Sep 16, 2014 8:26 am

Hello,

So in my 3.1.1 version I am trying to develop a plugin in accordance to this tutorial: http://docs.joomla.org/J3.x:Creating_a_ ... for_Joomla

I created my xml and php file. Plugin installs fine and I have activated it from Extension Manager. All I am trying to do for now is to echo hello world on onAfterRoute event since it is "global system event triggered on every page load" according to: http://docs.joomla.org/Plugin/Events/System

So now I should see hello world in source for any page on my website right? I don't...
My code:

Code: Select all

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class plgOffSiteRef extends JPlugin
{
    function onAfterRoute()
    {
        echo 'HELLO WORLD!';
    }
}
?>
Am I missing something?

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17425
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Simplest plugin won't work

Post by toivo » Tue Sep 16, 2014 12:40 pm

Am I missing something?
The name of the class has to follow the convention, as shown in the tutorial, and include the type of the plugin, for example plgSystemOffSiteRef would work.

The OnAfterRoute event is a bit too early to modify the page, which is usually done in content plugin events. If you use echo, you need an exit statement or something after it, otherwise you will not see the output from echo.
Toivo Talikka, Global Moderator

Pirs01
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Sep 10, 2014 11:52 pm

Re: Simplest plugin won't work

Post by Pirs01 » Tue Sep 16, 2014 3:43 pm

Thank you.


Locked

Return to “Joomla! 3.x Coding”