Php 如何删除joomla中的所有javascript?
我在这里使用代码Php 如何删除joomla中的所有javascript?,php,joomla,Php,Joomla,我在这里使用代码 <head> ... <?php $user =& JFactory::getUser(); if ($user->get('guest') == 1) { $headerstuff = $this->getHeadData(); $headerstuff['scripts'] = array(); $this->setHeadData($headerstuff); } ?> <jdoc:inclu
<head>
...
<?php
$user =& JFactory::getUser();
if ($user->get('guest') == 1) {
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array(); $this->setHeadData($headerstuff);
}
?>
<jdoc:include type="head" />
</head>
...
但是当运行代码是template load all javascript时,如何修复它?在template joomla中删除头中的所有javascript如果我正确理解了您的问题,您想删除头标记之间的所有javascript吗 如果是这样,您需要在
joomla_root\templates\
中找到模板的文件夹,并在其中打开index.php
(例如:joomla_root\templates\beez5\index.php
)(我建议先进行备份)。然后删除头部
标记之间以以下开头的所有内容:
addScript(
lines..您提供的行从另一个文件获取数据,因此它将是包含嵌入javascript文件的代码行的另一个文件。只需搜索
<script type="text/javascript"></script>
你也可能会发现像这样的东西
$document->addScriptDeclaration($variable);
<?php
//get the all the script declarations
$document = JFactory::getDocument();
$headData = $document->getHeadData();
$scripts = $headData['scripts'];
//if you want to remove all the script
unset($scripts);
//if you want to remove specific file then try like this
unset($scripts['/media/system/js/mootools-core.js']);
?>
//if you want to remove all the script
<?php unset($this->_scripts); ?>
//if you want to remove specific file then try like this
<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?>
要删除可在模板中使用的脚本,请执行以下操作:
$doc = JFactory::getDocument();
unset($doc->_scripts[$this->baseurl.'/media/system/js/mootools-core.js']);
我是这样做的:
$doc = JFactory::getDocument();
$doc->_scripts = array(); // just clear array
在这条线之前
<jdoc:include type="head" />
您可以从Joomla站点删除不需要的脚本
$document->addScriptDeclaration($variable);
<?php
//get the all the script declarations
$document = JFactory::getDocument();
$headData = $document->getHeadData();
$scripts = $headData['scripts'];
//if you want to remove all the script
unset($scripts);
//if you want to remove specific file then try like this
unset($scripts['/media/system/js/mootools-core.js']);
?>
//if you want to remove all the script
<?php unset($this->_scripts); ?>
//if you want to remove specific file then try like this
<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?>
或者像这样试试
$document->addScriptDeclaration($variable);
<?php
//get the all the script declarations
$document = JFactory::getDocument();
$headData = $document->getHeadData();
$scripts = $headData['scripts'];
//if you want to remove all the script
unset($scripts);
//if you want to remove specific file then try like this
unset($scripts['/media/system/js/mootools-core.js']);
?>
//if you want to remove all the script
<?php unset($this->_scripts); ?>
//if you want to remove specific file then try like this
<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?>
//如果要删除所有脚本
//如果要删除特定的文件,请尝试以下操作
您可以应用
之前的任何方法。它将删除所有脚本
希望这会对您有所帮助。您需要它做什么?您想将所有js调用移到页面的页脚吗?-有很多原生joomla插件用于所有这些类型的优化