Similar content

Loading

Powered by Canoo FindIT.

Resources

The Resources module makes it possible to store and manage site resources such as cascading style sheets, JavaScript and images in the repository. Such resources are typically non-editorial static assets. They are not edited on a daily basis but managing and editing them in AdminCentral makes site administration easier. The module creates a resources workspace in the repository and makes it available in the Templating Kit > Resources menu. The module is a complementary module in that it does not function independently, but rather extends the functionality of the Standard Templating Kit.

See Themes and Resources in the Standard Templating Kit documentation for more information.

Download

Download the Resources module from Magnolia Store or Nexus repository.

Installing

Resources is a community module included in the Standard Templating Kit bundle and is typically already installed. Go to Magnolia Store > Installed modules in AdminCentral to check. To install the module individually, see the general module installation instructions. In order to use this module, the STK needs to be installed.

Uninstalling

See the general module uninstalling instructions and advice.

Configuration

The Resources module requires no configuration. On installation the module creates the following configuration at Configuration > /modules/resources

Tree

The trees node registers the Templating Kit > Resources tree in AdminCentral. The Standard Templating Kit module installs the JavaScript and CSS files in the tree.

Templates

The templates node registers the template definitions for the resource types used in Templating Kit > Resources.

All template definitions use the ResourceTemplate Java class that extends the ConfiguredTemplateDefinition class to allow for the processed and contentType properties in the definitions. These properties distinguish processed and non-processed JavaScript and CSS files. When a resource is of type Processed, its content is interpreted as a FreeMarker template. You can use FreeMarker constants, variables and expressions inside the resource.

Each definition:

  • References its own template renderer in the renderType node.
  • Links to a dialog in the dialog node.
  • Registers the FreeMarker content type in the contentType node. The reference template defintion does not require this property.

Dialogs

The definitions of the dialogs used in Templating Kit > Resources are configured in the dialogs node. These dialogs are used to create and edit the different resource types. See Usage below.

Template renderers

The renderers node registers the required template renderers.

RendererClassPurpose
textResourceResourcesTextTemplateRendererAllows for the interpretation of FreeMarker notations in processed resources. This renderer uses the content and its subnodes as a FreeMarker template.
binaryResourceResourcesBinaryRendererStreams the binary data stored in the content.
referenceResourceReferenceResourceRendererResolves the referenced resource and triggers the rendering of the referenced resource node.

Usage

To create a new resource item:

  1. Click New Item.
  2. Name the item and select the resource type.
  3. Click Edit Item or double-click on the file icon.
  4. Fill fields in the dialog.
  5. Save.

JavaScript and CSS files

JavaScript and CSS files (both processed and non-processed) are created in the text dialog. The Content field uses the editCode control for entry of CSS or JavaScript code.

In the Advanced tab:

  • Bypass: If checked, the resource is loaded by the standard mechanism which loads from the file system or classpath resources. If unchecked, the resource is loaded from the repository. The first is the recommended best practice while the latter is useful during learning and development.
  • Extension: The script extension is added to the path if Bypass is selected.
  • Model Class: Allows for the use of a model class other than that in the template definition, which is overridden.

Binary files

The binary dialog allows for the upload of binary files such as images to the resources workspace.

The template images used by the pop and pop-mobile themes are stored in the resources workspace.

Referenced files

The reference dialog is used by aggregator JavaScripts to link to individual scripts stored in folders within the resources workspace.

This mechanism makes the individual scripts easily available for aggregation. For example jquery.tabtree is used by both the scriptloader-plugin and mobile-scriptloader-plugin aggregator scripts.

Security

On installation, the module creates the resources-base role that grants the following permissions:

SpacePermissionScopePath
ResourcesRead/WriteSelected and sub nodes/
ConfigRead onlySelected and sub nodes/modules/resources
 Read onlySelected and sub nodes /modules/adminInterface/config/menu/templating-kit/resources
 Read onlySelected node /modules/adminInterface/config/menu/templating-kit

These permissions are also included in the superuser role, but are not granted to any other default user or group. The demo-project-base and anonymous roles grant Read Only permissions to the resources workspace.

Alternative access methods

You can also access resources using the WebDav module or the CMIS module.

Documentation

See the Standard Templating Kit documentation for how resources are used in the STK: