0
我只是想添加一个js文件,但我不能得到它的工作...我用Google搜索,但没有发现任何帮助,但..任何帮助是非常appreacheated添加JS中的Joomla 2.5插件
这是我的代码:
所有的<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.plugin.plugin');
class plgSystemInfinityScroll extends JPlugin {
protected $_execute;
function __construct(&$subject, $config) {
$app = JFactory::getApplication();
if($app->isAdmin())
{
return;
}
parent::__construct($subject, $config);
$this->loadLanguage('', JPATH_ADMINISTRATOR);
$this->_execute = true;
}
public function onBeforeCompileHead() {
$document =& JFactory::getDocument();
$document->addScript('/plugins/system/sjdinfinitescroll/jquery.infinitescroll.js');
}
public function onAfterRender() {
}
}
是你的插件安装并启用?事件是否被调用?尝试在构造函数和事件中调用'JFactory :: getApplication-> enqueMessage('message')'来查看脚本的行为。 – Alex 2012-04-29 00:42:59
那么,如果我在onBeforeCompileHead函数中添加它会中断网站..但是如果我将它放在__construct中没有更改..:/ – Mackelito 2012-04-30 10:17:09
听起来不正确,'enqueMessage'只是添加要显示的消息。如果您正在运行php4,则必须使用'public function plgSystemInfinityScroll'而不是'__construct',应始终调用构造函数。我在prev中犯了一个错字。评论,它应该是'JFactory :: getApplication() - > enqueMessage('xxx')'。 – Alex 2012-04-30 12:36:04