Reputation: 51
I'm developing a Joomla system plugin and I need to add some scripts in the header, I've the following code:
defined('_JEXEC') or die('Restricted access');
jimport('joomla.plugin.plugin');
class PluginSystemMyPlugin extends JPlugin {
function PluginSystemMyPlugin(&$subject, $config){
parent::__construct($subject, $config);
$this->_plugin = JPluginHelper::getPlugin('system','myplugin');
$this->_params = new JParameter($this->_plugin->params);
$this->_mainframe= &JFactory::getApplication();
if($this->_mainframe->isAdmin())return;
}
function onAfterInitialise(){
if($this->_mainframe->isAdmin())return;
$loadjquery = $this->params->get('loadjquery');
$document =& JFactory::getDocument();
if($loadjquery=='yes'){
JHTML::_(' behavior.mootools');
$document->addScript("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js");
}
$document->addScriptDeclaration('
jQuery.noConflict();');
}
}
I've also tried addScriptDeclaration(), addStyleSheet(), addStyleSheetDeclaration(), none working. My Joomla version is 1.5.23. I've tried others plugin with the same declarations in onAfterInitialise() and they worked, why not mine?
Upvotes: 0
Views: 1328
Reputation: 4461
Have you installed it correct? Have you published it? Are you sure that your plugin is run? Have you tried to debug your plugin code with die
function to detect whether it works? Also you could try this http://docs.joomla.org/JDocumentHTML/addCustomTag
Upvotes: 0
Reputation: 51
I've found the errors:
class PluginSystemMyPlugin extends JPlugin {
function PluginSystemMyPlugin(&$subject, $config){
must to be:
class plgSystemMyPlugin extends JPlugin {
function plgSystemMyPlugin(&$subject, $config){
Upvotes: 1