3.4.3.1. Adding custom style

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

eXo Platform allows to inject new CSS files by configuration, by declaring them in a file WEB-INF/gatein-resources.xml in an extension webapp.

Portal skin

New CSS files can be added to a portal skin, meaning they are loaded in all the pages of the sites using this skin. For example, in order to add a new CSS file to override some styles of the Default skin, the following configuration must be defined in the file WEB-INF/gatein-resources.xml:


<gatein-resources>
    <portal-skin>
        <skin-name>Default</skin-name>
        <css-path>/skin/my-style.css</css-path>
        <skin-module>MyStyle</skin-module>
        <css-priority>0</css-priority>
        <overwrite>false</overwrite>
    </portal-skin>
</gatein-resources>
      

In which:

Once deployed, the CSS file /skin/my-style.css will be loaded in all the pages of the sites which use the Default skin. CSS files will be loaded as link tags in the head section of the web page, following a defined Loading strategy, so before the portlets CSS files.

Tip

A sample Maven project is available here as a working example to customize a skin.

Portal skin - Custom Module

Since the Portal skin stylesheets are loaded before the Portlets skin stylesheets, portlets style overrides the portal style. While this is very useful to control the style of a portlet no matter what the portal style is, it can be a problem when a portal style must be applied on all portlets no matter what the portlets style is. eXo Platform provides the capability to define portal CSS files which can be loaded after portlet CSS files. They must be declared in the file WEB-INF/gatein-resources.xml like portal CSS files. The only difference is that they must have a skin-module tag starting with customModule:

<!-- XML : generated by JHighlight v1.0 (http://jhighlight.dev.java.net) -->
<span class="xml_tag_symbols">&lt;</span><span class="xml_tag_name">gatein-resources</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="xml_tag_symbols">&lt;</span><span class="xml_tag_name">portal-skin</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="xml_tag_symbols">&lt;</span><span class="xml_tag_name">skin-name</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain">Default</span><span class="xml_tag_symbols">&lt;/</span><span class="xml_tag_name">skin-name</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="xml_tag_symbols">&lt;</span><span class="xml_tag_name">css-path</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain">/skin/my-custom-module-style.css</span><span class="xml_tag_symbols">&lt;/</span><span class="xml_tag_name">css-path</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="xml_tag_symbols">&lt;</span><span class="xml_tag_name">skin-module</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain">customModuleMyStyle</span><span class="xml_tag_symbols">&lt;/</span><span class="xml_tag_name">skin-module</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="xml_tag_symbols">&lt;</span><span class="xml_tag_name">overwrite</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain">false</span><span class="xml_tag_symbols">&lt;/</span><span class="xml_tag_name">overwrite</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="xml_tag_symbols">&lt;/</span><span class="xml_tag_name">portal-skin</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_tag_symbols">&lt;/</span><span class="xml_tag_name">gatein-resources</span><span class="xml_tag_symbols">&gt;</span><span class="xml_plain"></span><br />
<span class="xml_plain">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br />

Portlet skin

Portlets often require additional styles that may not be defined by the portal skin. eXo Platform allows to define additional stylesheets for each portlet and appends the corresponding link tags to the head. Here is an example that can be added in the file WEB-INF/gatein-resources.xml to define a new CSS file to be included whenever the portlet WhoIsOnLinPortlet is available on a portal page:


<gatein-resources>
    <portlet-skin>
        <application-name>homepage-portlets</application-name>
        <portlet-name>WhoIsOnLinPortlet</portlet-name>
        <skin-name>Default</skin-name>
        <css-path>/skin/WhoIsOnLinPortlet/my-portlet-style.css</css-path>
        <css-priority>1</css-priority>
        <overwrite>false</overwrite>
    </portlet-skin>
</gatein-resources>
        

In which:

This example tells eXo Platform to load the CSS file /skin/WhoIsOnLinPortlet/my-portlet-style.css when the portlet WhoIsOnLinPortlet of the webapp homepage-portlets is displayed on the page. As for sites, CSS files will be loaded as link tags in the head section of the web page. The ID attribute of <link> element uses the pattern portletAppName_PortletName. In the above example, the ID of the link is "homepage-portlets_WhoIsOnLinPortlet".

The portlet can be any native eXo Platform portlet or any custom portlet.

Note

The full schema for gatein-resources.xml files can be found at https://www.exoplatform.com/xml/ns/gatein_resources_1_4.xsd.

Customizing the Enterprise Skin

The Enterprise Skin (available only in Enterprise Edition) has been done as a new skin, using the customStyle.less file. It means that its CSS style is loaded as a portal skin custom module, so after all the others type of stylesheets, as described in the CSS priority chapter.

In order to customizing styles defined in the Enterprise Skin, a portal skin custom module must be used, with a higher priority.

Changing portlet icons

Each portlet can be represented by a unique icon that you can see in the portlet registry or page editor. This icon can be changed by adding an image to the directory of the portlet webapplication: skin/DefaultSkin/portletIcons/icon_name.png.

To use the icon correctly, it must be named after the portlet. For example, the icon for the Hello portlet named HelloPortlet is located at: skin/DefaultSkin/portletIcons/HelloPortlet.png.

Note

You must use skin/DefaultSkin/portletIcons/ for the directory to store the portlet icon regardless of which skin is going to be used.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus