O'Reilly logo

Designing for XOOPS by Sun Ruoyu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required