-
Templating and Integration Guide
- Part 1: Concepts
- Part 2: Modules
- Part 3: Templates and Studio
- Part 4: Content Definitions and Views
- Part 5: Advanced Techniques
- Part 6: Setting up an integration environment
- Part 7: Step by step integration
- Further reading and resources
CSS / Javascript integration
We will now start integrating the CSS and Javascript files into the template set. First let’s copy the CSS files into the new module’s css directory, and do the same for the Javascript files into the javascript directory.
We will then use the <template:addResource/> tag to reference these elements from the JSP script. In order to have a solid integration with themes and Jahia’s Edit mode, it is recommended to use the addResource tag instead of using HTML link tags. However if you want to provide CSS files for different render mode such as the print mode, you might want to reference them directly using the link tag.
The next step is to add the bodywrapper class which will protect the rendering in Eidt mode. It is mandatory to either:
- modify the CSS if it modifies the default HTML tags and prefix them with .bodywrapper
- add a CSS for the Edit mode that redefines these tags by prefixing them with .bodywrapper
Example
The original CSS file might look like this:
p {
display:none;
}
And once modified it will look like this:
.bodywrapper p {
display:none;
}
A more complete example
If to start with in the original HTML we had the following header section:
<head>
<link rel="stylesheet" type="text/css" href="css/template1.css" />
<link rel="stylesheet" type="text/css" href="css/template2.css" />
<link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
</head>
Once the CSS have been copied into the css directory, the header will then become:
<head>
<link rel="stylesheet" type="text/css" href="<c:url value='${url.currentModule}/css/print.css'/>" media="print" />
</head>
<body>
<div class=”bodywrapper”>
…
</div>
<template:addResources type="css" resources="template1.css,template2.css/>
</body>
Warning: for the template’s view, it is important to add the addResource tag at the end of the file, as the external resources are evaluated in there order of inclusion, which means that the template’s CSS files should be loaded last. Don’t worry about the tags not being in the <head> HTML tag, Jahia will actually insert them in the proper location.
Once the template has been deployed, we now obtain the proper mockup look and feel.
![jahia6_6_integration_en-72.png [image]](/files/live/sites/jahiacom/files/documentation/6.6/en/images/IntegrationGuide/jahia6_6_integration_en-72.png)

