Skin Module

The Skin module provides the tools and API to access skin resources. 

The SkinManager component is the main entry point of the module and each skin is represented by a Skin interface which is mostly a ResourceRepository. This interface provides the API for navigating to the resources located in the skin and most importantly, it takes into account the skin inheritance.

Examples

1. Retrieve the skin having the ID "xwiki:Main.MySkin".

import org.xwiki.skin.SkinManager;
import org.xwiki.skin.Skin;

@Inject
SkinManager skinManager;

Skin myWikiSkin = skinManager.getSkin("xwiki:Main.MySkin");

2. Retrieve the current skin.

import org.xwiki.skin.SkinManager;
import org.xwiki.skin.Skin;

@Inject
SkinManager skinManager;

// Since it is not important whether the current user has the right to access the current skin,
//the parameter is set to false
Skin currentSkin = skinManager.getCurrentSkin(false);

3. Recursively search the resource "myscript.js" in the current skin.

import org.xwiki.skin.SkinManager;
import org.xwiki.skin.Skin;
import org.xwiki.skin.Resource;

@Inject
SkinManager skinManager;

// Retrieve the first skin on which the current user has access rights
Skin currentSkin = skinManager.getCurrentSkin(true);

// Check whether the resource is the skin or one of its parents
Resource myresource = currentSkin.getResource("myscript.js")

// Print the skin where the resource was found
System.out.println(myresource.getRepository());

// The resource is the skin itself only
Resource myskinresource = currentSkin.getLocalResource("myscript.js")

   

Related Pages

Trying to decide between Cloud and On Premise? See the comparison on the XWiki Help Center.

Search this space