2014-06-18 51 views
2

我突然开始收到以下错误: 未捕获的ReferenceError:没有定义jQuery。Joomla 331 Uncaught ReferenceError:没有定义jQuery

我不是很流利的PHP,所以请善待。 LOL从index.php文件模板

我的头代码:

<head> 
<jdoc:include type="head" /> 
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/system.css" /> 
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/general.css" /> 

<!-- Created by Artisteer v4.2.0.60623 --> 


<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width" /> 

<!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> 
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.css" media="screen" /> 
<!--[if lte IE 7]><link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" /><![endif]--> 
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.responsive.css" media="all" /> 
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans&amp;subset=latin" /> 
<link rel="shortcut icon" href="<?php echo $templateUrl; ?>/favicon.ico" type="image/x-icon" /> 

<script>if ('undefined' != typeof jQuery) document._artxJQueryBackup = jQuery;</script> 
<script src="<?php echo $templateUrl; ?>/jquery.js"></script> 
<script>jQuery.noConflict();</script> 
<script src="<?php echo $templateUrl; ?>/script.js"></script> 
<script src="<?php echo $templateUrl; ?>/script.responsive.js"></script> 
<script src="<?php echo $templateUrl; ?>/modules.js"></script> 
<?php $view->includeInlineScripts() ?> 
<script>if (document._artxJQueryBackup) jQuery = document._artxJQueryBackup;</script> 

回答

4

这是因为你<jdoc:include type="head" />后加载jQuery的。您应该加载jQuery的这条线之上,甚至更好,使用以下命令:

JHtml::_('jquery.framework'); 

所以,你最终的代码如下:

<head> 
<?php JHtml::_('jquery.framework'); ?> 

<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width" /> 
<link rel="shortcut icon" href="<?php echo $templateUrl; ?>/favicon.ico" type="image/x-icon" /> 
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans&amp;subset=latin" /> 
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/system.css" /> 
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/general.css" /> 
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.css" media="screen" /> 
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.responsive.css" media="all" /> 

<!--[if lt IE 9]> 
    <script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 
<![endif]--> 
<!--[if lte IE 7]> 
    <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" /> 
<![endif]--> 

<jdoc:include type="head" /> 
<script src="<?php echo $templateUrl; ?>/script.js"></script> 
<script src="<?php echo $templateUrl; ?>/script.responsive.js"></script> 
<script src="<?php echo $templateUrl; ?>/modules.js"></script> 
<?php $view->includeInlineScripts() ?> 
<script>if (document._artxJQueryBackup) jQuery = document._artxJQueryBackup;</script> 

正如你可能已经注意到,我身边换几件事情所以订单有点干净。

在一个侧面说明,我也建议您简单地删除这样的:

<!--[if lte IE 7]> 
    <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" /> 
<![endif]--> 

如Internet Explorer是非常老不应该有任何理由,你为什么必须支持它。

希望这会有所帮助

+0

谢谢Lodder !! 我把这个网站倾倒在我的腿上,我正在学习。 – user3753135

+0

@ user3753135 - 不客气。如果这解决了您的问题,请点击勾号图标接受答案 – Lodder

相关问题