2012-05-21 101 views

回答

23

有兩種方法,我知道的:

1)得到一個例如,如果文檔對象和刪除JS文件(你可以做,在一個插件):

<?php 
     //get the array containing all the script declarations 
     $document = JFactory::getDocument(); 
     $headData = $document->getHeadData(); 
     $scripts = $headData['scripts']; 

     //remove your script, i.e. mootools 
     unset($scripts['/media/system/js/mootools-core.js']); 
     unset($scripts['/media/system/js/mootools-more.js']); 
     $headData['scripts'] = $scripts; 
     $document->setHeadData($headData); 
?> 

2 )直接從你的模板的index.php刪除js文件:

<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?> 
0

您只需編輯這些插件代碼來刪除這些文件。或者在不需要的情況下卸載這些插件。

-7
**An easiest way to disable mootools/ unwanted javascripts for your site in joomla cms (2.5 version)**(still loads it for your admin) 


**Step-1:** 
Using your favorite file editor, open for edit: 
libraries/joomla/document/html/renderer/head.php 

**Step-2:** check for code in head.php 

// Generate script file links 
foreach ($document->_scripts as $strSrc => $strAttr) 
{ 
// *** start *** // 
$ex_src = explode("/",$strSrc); 
$js_file_name = $ex_src[count($ex_src)-1]; 
$js_to_ignore = array("mootools-more.js","core.js"); // scripts to skip loading 
//skip loading scripts.. 
if(in_array($js_file_name,$js_to_ignore) AND substr_count($document->baseurl,"/administrator") < 1 AND $_GET['view'] != 'form'){continue;} 
// *** end *** // 


**Step-3:** 
Clear cache & refresh page. 


it works for sure. 

For detailed explanation : http://www.inmotionhosting.com/support/edu/joomla-25/302-disable-mootools-in-joomla-25 
+5

不建議修改核心文件 – betweenbrain

5

如果您要刪除所有腳本喬omla增加,包括聯腳本,最快的方法是這樣的:

$this->_script = $this->_scripts = array(); 

添加在上面的<head>部分模板文件這在任何地方。

相關問題