Adding support for JQuery as module in modular theme

I wanted to try adding a custom module in the Modular theme so i started reading the Using jQuery in a theme wiki page and i made few changes in the steps to get it working in my local. It seems that the source code for all the modules that are part of Portal 7002 modular theme is stored in the .war file in WebSphere\PortalServer\theme\wp.theme.modules\webapp\installedApps\ThemeModules.ear\ThemeModules.war\modules
Now we are not supposed to add any code in the WebSphere\PortalServer directory because when you install new fix or fix pack your changes could get overwritten, so i did create a new HelloModular.war file that has all the static resources as well as plugin.xml file that defines the static resources in my theme. You can download the HelloModular.war file with all the source code from here, i followed these steps
  1. First i did create HelloModular as Dynamic Web Application(basically a .war file) in RAD
  2. Then i did copy the jquery.min.js(I got the latest version from JQuery Web Site), jSquishy.css,jSquishy.js,jSquishy.jsp(I got the jSquishy related files from Portal Wiki) in the WebContent folder so that they will be available at the root of the HelloModular web application. This is how my project structure looks like
  3. After that i had to create plugin.xml that defines the jQuery and jSquishy related modules like this
    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.0"?>
       name="jQuery module contributions"
            <!-- jQuery js -->
     <extension point="" 
      <module id="jQuery">
       <prereq id="wp_portal"/>
       <contribution type="head">
        <sub-contribution type="js">
      <uri value="res:/HelloModular/jquery.min.js" />
     <extension point="" 
      <module id="jSquishy">
       <prereq id="jQuery"/>
       <contribution type="head">
        <sub-contribution type="css">
      <uri value="res:/HelloModular/jSquishy.css" />
        <sub-contribution type="js">
      <uri value="res:/HelloModular/jSquishy.js" />
       <contribution type="config">
        <sub-contribution type="markup">
      <uri value="res:/HelloModular/jSquishy.jsp"/>
    The jquery.min.js is available at http://localhost:10039/HelloModular/jquery.min.js so i had to define it like res:/HelloModular/jquery.min.js while declaring it as a module.
  4. The last step was to create a profile_jquery.json like this
     "moduleIDs" : [
    After creating this profile_jquery.json i did upload it to /fs-type1/themes/Portal7.0.0.2/profiles/ folder in WebDAV
  5. Last step was to restart the changes for new module definition to get applied
  6. I did change the profile applied to one of my test page to profile_jquery.json by following steps defined in Changing the profile for a page
Now this is how my portal page looks like with squishy in both header and footer
When i looked at the request flow in the Firebug i can see the jQuery related resources being included. Follow the steps in Disabling combining of resource for debugging modular theme so that you can see individual request for resource.

1 comment:

Joyce James said...

Great post. Finding ideas to write about is one of the hardest things about running a blog. Please visit