By IAmCorbin on
I just spent the day getting mootools working on the Drupal site I am developing. I am new to Drupal and didn't know how to even get custom JavaScript working with it yet.
Here is how I did it:
I added these two lines to my theme's 'page.tpl.php' file:
<script type="text/javascript" src="<?php print base_path() . path_to_theme() ?>/mootools-1.2.4-core.js"> </script>
<script type="text/javascript" src="<?php print base_path() . path_to_theme() ?>/myMootools.js"> </script>
so now the head section for my theme looks like this:
<head>
<?php print $head ?>
<title><?php print $head_title ?></title>
<?php print $styles ?>
<?php print $scripts ?>
<script type="text/javascript" src="<?php print base_path() . path_to_theme() ?>/mootools-1.2.4-core.js"> </script>
<script type="text/javascript" src="<?php print base_path() . path_to_theme() ?>/myMootools.js"> </script>
<script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE */ ?> </script>
</head>
And since as of mootools version 1.2.3 there is a new Dollar Safe Mode in which Mootools will not steal the $ from jQuery. I have not seen this mentioned anywhere on the forums and it is a much easier solution than rewriting the jQuery code that I have seen some suggest.
Comments
Great stuff!
Perhaps it will be easier for others to find if you add it to the docs: http://drupal.org/node/121997
You could generalise it to 'Including other js libraries' and use mootools as an example
However there might be a better way to achieve what you just did. Inserting the mootools scripts independently of
print $scriptsmeans your new scripts cant take advantage of js caching.It may be better to declare them in the .info file of the theme you are using (http://drupal.org/node/171205). Or, if you want your solution to be theme independent, to write a small module and declare it there.
subscribing
subscribing