Directory & Hook Structure

Skinr plug-ins can be created inside modules and themes. When writing skins that are specific to single theme, it makes sense to include them in a theme, as that’s the only place they’ll be available. However, if your skins can be used across a multi-site installation or by multiple themes, then it may make more sense to include them in a module instead.

Defining the API version and directory

The directory will contain your skin plug-ins and can be set to whatever you choose. The current API version is 2. This maps to the branch of the current release, currently 7.x-2.x. The directory structure and hooks used to create skins differ depending on which you decide to use, which we cover below.

Modules

Modules define the API version and directory by implementing hook_skinr_api_VERSION() in .module files.

<?php
/**
 * Implements hook_skinr_api_VERSION().
 */
function modulename_skinr_api_2() {
  return array(
   
'directory' => 'skins',
  );
}
?>

Themes

Themes define the API version and directory in .info files. Defining the API is required, but the directory is optional for themes. Skinr will check for a skins directory by default. However, you can change this to whatever you want.

skinr[api] = 2
skinr[directory] = skins

Hook and File Structure

When your module or theme will only contain one skin implementation, and you are not worried about file directory structure, you'll create a file named hook.skinr.inc, where hook is the name of your module or theme and place it in the root of your module or theme directory. In this case, you'll use hook_skinr_skin_info() to implement your skins.

When you will have one or more skin plug-ins, you'll set use the following directory structure: skins/plugin/plugin.inc. This is useful when you need to create separate directories for your skins to neatly organize their assets. In the example below, we've named the plug-in "example." This dictates both the name of the directory and .inc file in your skins directory. It also uses hook_skinr_skin_PLUGIN_info().

Single skin plug-in per module or theme

File: sites/all/themes/mytheme/mytheme.skinr.inc

<?php
/**
 * Implements hook_skinr_skin_info().
 */
function mytheme_skinr_skin_info() {
  ...
}
?>

Multiple skin plug-ins per module or theme

File: sites/all/themes/mytheme/skins/example/example.inc

<?php
/**
 * Implements hook_skinr_skin_PLUGIN_info().
 */
function mytheme_skinr_skin_example_info() {
  ...
}
?>