In Joomla 2.5 I have installed DirectPHP, which I have used extensively in Joomla 1.6 to embed PHP in Joomla articles. It works very well. I usually just for one include in the article, like this:

<?php
    include "my_cool_script.php";
?>

Then I make my code in my_cool_script.php. One thing I often do is include more JS or CSS scripts in the page, right through the article, but putting the following lines in my_cool_script.php:

<link rel="stylesheet" type="text/css" media="screen" href="/scripts/css/dark-hive/jquery-ui-1.8.21.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/css/ui.jqgrid.css" />
<script src="/scripts/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/scripts/js/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<script src="/scripts/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="/scripts/js/jquery.jqGrid.src.js" type="text/javascript"></script>

This has always worked in the past, with Joomla 1.6. Now in the Joomla 2.5 install. The rest of the PHP and HTML is loading in the article, and there aren't any errors on the page as far as loading the scripts. I look at the HTML code and I can see the above lines written to the page, but I cannot access any of the jQuery functions, like the script was not loaded. I get an error when I try to use any jQuery syntax. I know this script was working, because I just moved it from another site, running joomla 1.5 to the new one, 2.5.

Does anyone know anything about why the scripts aren't loading?

EDIT

Well i guess the script was loading, but it didn't like that used the $ symbol. I changed them all to jQuery and it works.

有帮助吗?

解决方案

I am not sure exactly why, but perhaps in my installation there is some conflict, and the $ symbol is being recognized as it usually does, signifying that we are dong jQuery. So I changed all the $ to jQuery in my PHP scripts and all the jQuery seems to be working now.

其他提示

Mootools (Joomla's javascript default framework until version 2.5) also uses '$', so it's very easy to run into some complications if you're unaware you're running scripts relying on both frameworks side to side.

Having said that, you could use 'jQuery' instead of '$' and release '$' for everyone else using the jQuery.noConflict(); command.

Cheers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top