I've just started learning Joomla. Please advise how to make use of onAfterInitialise()
event.I just want to see how things work through Joomla plugin. For now I just want to display 'Some text' in home page or in all pages when page loaded with this plugin.
With the help of some tutorials online, I've created plugin as following and installed and activated it. Just don't know how to make use of it!
XML file chat.xml
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="System">
<name>Chat</name>
<author>Apple</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2016 mysite.com.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>apple@mysite.com</authorEmail>
<authorUrl>www.mysite.com</authorUrl>
<version>3.1.0</version>
<description>This is a chatting plugin</description>
<files>
<filename plugin="categories">chat.php</filename>
<filename>index.html</filename>
</files>
</extension>
PHP file chat.php
<?php
// no direct access
defined( '_JEXEC' ) or die;
jimport( 'joomla.plugin.plugin' );
class plgSystemChat extends JPlugin
{
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
}
protected $autoloadLanguage = true;
function onAfterInitialise()
{
echo "<h1>test plgContentConversekit</h1>";
return true;
}
}
?>
And index.html
with following code in it:
<!DOCTYPE html><title></title>
I found a way to make use of onAfterInitialise(). Below I used it to add script and stylesheet on page load.
function onAfterInitialise() {
// Load Bootstrap
JHtml::_('jquery.framework');
JHtml::_('bootstrap.framework');
$document = JFactory::getDocument();
$document->addStyleSheet(JURI::base(). "plugins/system/conversekit/conversekit.css");
$document->addScript("plugins/system/conversekit/conversekit.js", "text/javascript", false, false);
return true;
}