[英]Development of a module joomla
我正在尝试使用jquery开发一个简单的模块,但是我想禁用mootools。 我尝试在default.php文件中使用此代码
$user =& JFactory::getUser();
if ($user->get('guest') == 1) {
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array();
$this->setHeadData($headerstuff); }
<jdoc:include type="head" />
但是我得到这个错误:不在对象上下文中时使用$ this ....
我等你的建议
我认为您在做什么不是一个好主意。 如果要使用jQuery,则将其包括在noconflict模式下,并使用jQuery
而不是$
来引用它。
但是,无论如何,这就是您想要的代码。 $this
应该是JDocument
对象,因此您需要先获取它。
$user = JFactory::getUser();
if ($user->get('guest') == 1) {
$doc = JFactory::getDocument();
$headerstuff = $doc->getHeadData();
$headerstuff['scripts'] = array();
$doc->setHeadData($headerstuff);
}
我猜您想编辑html文档属性。 因为setHeadData()是某些Joomla类的方法,您会收到错误消息。 您不能在课堂外使用$ this。
尝试获取文档对象并按如下所示调用setHeadData:
$doc =& JFactory::getDocument();
$doc->setHeadData($headerstuff);
无论如何,您可以同时使用jQuery和mootools。 只需关注这篇文章: http : //davidwalsh.name/jquery-mootools
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.