# Overview of plugging into Orion pages

An important part of plugging into Orion pages is supplying links that connect the user to other pages inside and outside of Orion. Page-level linking services allow plugins and page authors to contribute links and other forms of connectivity between an Orion page and other web pages. The most general of these services can be used on any Orion page.

When specifying links to other pages, a service may need to use some information about the page to decide whether a link is applicable and how the link is composed. This is accomplished for many services by using the `validationProperties`, `uriTemplate`, and `contentType` properties in the service definition.

## Validation Properties

Validation properties describe the properties of a page object that should be analyzed to determine whether a particular service applies to the page. They can optionally store information from page objects into variables that can be referenced in a URI template. Linking services generally specify one or more of these properties in an array. The general format of an individual validation property is as follows:

source
  `String` The name of a property to look for in the target object. The ":" character represents nested properties, and the "|" character represents OR'ed properties. For example, the source `Location` specifies that the page object must have a "Location" property, such as `myObject.Location`. The source `Git:ContentLocation` specifies that the page object must have a sub-object and property such as `myObject.Git.ContentLocation`. The source `ChildrenLocation|ContentLocation` means that the page object must have either a property such as `myObject.ChildrenLocation` or a property such as `myObject.ContentLocation`. The first property found will be used.
match
  `Object` A value used to validate the source property. In general, the value of the page object's property will be compared against this value. However, if this value is a string, the string is assumed to specify a regular expression that will be passed to the RegExp constructor.
variableName
  `String` Optional. The name of a variable that represents the value of the source property. If specified, then an associated URI template may use a variable of this name, and it will contain the value of the matched source property.
variableMatchPosition
  `String` Optional. A string that specifies what part of a matching string is used in the variable value when a regular expression was used to match the property.

- `"all"` (default) means the entire property value should be substituted for the variable.
- `only` means only the matching part of the property value should be substituted in the URI template.
- `before` means the part before the match is substituted in the URI template.
- `after` means the part after the match is substituted in the URI template.

replacements
  `Array` Optional. Specifies an array of replacements (pattern and replace strings) that can be used to further modify a variable value used in a URI template.

## URI Templates

URI templates describe the link to another page. Variables in the URI template can refer to the page object metadata, to variables named in the validation properties, or to special variables defined in Orion. Variables are referenced using curly brackets. The following variables are system wide variables (independent of the page object or variable names in the validation properties).

OrionHome
  Specifies the hostname for the Orion server instance. This variable can be used by a plugin that is installed in another domain to reference a page location in Orion.

For example, the URI template `{+OrionHome}/content/content.html#{+Location}` links to a particular page (content.html) in the running Orion instance, and includes the value of the `Location` property in the originating page's object metadata after the hash. Note that we prefix variables with `+` in the template to indicate that their value should not be percent-encoded when the template is expanded. This is required for any variables that we expect to contain raw URL characters like `'/'`, which would otherwise be encoded to `%2F` by the template engine.

The URI Template syntax is specified by RFC 6570.

## Content Types

Content types may be used to further validate file-based metadata. For example, if a page link should only be visible when the page is showing HTML or CSS, a content type of `"text/css"` can be used to express this.