Chapter 5. jQuery and UI Libraries for XOOPS Themes

Several years ago, when I needed to add animations to my web design, Flash was the first word that came into my mind. But nowadays, with the rapid development of JavaScript and its related libraries, I seldom use Flash in general web design. JavaScript has taken over many roles that used to be filled by Flash. In this chapter, I will cover how to use one of the most popular JavaScript libraries, jQuery, in XOOPS themes.

The first method that comes to your mind should be adding:

<script src=" https://ajax.googleapis.com/ajax/libs/jQuery/1.6/jQuery.min.js"
    type="text/javascript"></script>

to the <head> section of theme.html.

This is very intuitive, and will work without too many disturbances. But you may ask: What disturbances might we encounter?

Look back at A Simple Example in Chapter 2, where I first introduced a bare bones theme. You might notice that there is a <{$xoops_module_header}> in the <head> section. This tells XOOPS to load the header required by specific modules—which allows a module to load what it needs on demand, instead of loading the files for the whole of XOOPS.

A common example is an editor’s JavaScript and stylesheet. As jQuery is very popular, many modules will load jQuery on demand. However, if you use the above code to load jQuery in your theme, it will be loaded again for some modules, thus causing some malfunctions (such errors will only happen in modules that load jQuery on demand, ...

Get Designing for XOOPS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.