# orion.page.link.related

The related link service provides a mechanism for plugins to contribute links to the "Related pages" menu in the Orion page header. Clients can specify when the link is applicable using `validationProperties` and `contentType`.

## Service methods

None. This service is purely declarative.

## Service attributes

Implementations of `orion.page.link.related` must define the following attributes:

id
  A symbolic id for referencing this link.
name
  A human readable link name, used in the "Related pages" menu.
tooltip
  A tooltip used to describe the link.
uriTemplate
  A URI Template

    that defines the link.  This template may use page object metadata, declared variable names, or standard Orion URI template variables.

contentType
  Optional. An array of Content Type IDs for which this link is applicable.
validationProperties
  Optional. An array of Validation Properties describing whether the link is applicable, and optionally declaring variables to be used in the URI template.

## Examples

The following related page link will determine if the current page's target has a `GitUrl` that conforms to the URL of git repositories hosted at github.com. If so, then parts of the URL are assigned to variables that are used to build the associated github URL.

    provider.registerServiceProvider("orion.page.link.related", null, {
       id: "orion.git.gotoGithub",
       name: "Show in GitHub",
       tooltip: "Show this repository at GitHub",
       validationProperties: [{
          source: "GitUrl",
          match: "github\.com.*\.git",
          variableName: "GitHubLocation",
          variableMatchPosition: "only",
          replacements: [{pattern: ":", replacement: "/"}, {pattern: ".git$", replacement: ""}]
       }],
       uriTemplate: "https://{GitHubLocation}"
    });

If the service extension does not describe a name, tooltip, and uriTemplate, the implementation will look for a command extension of the same id. In this way, commands added to the navigator that link to other pages may be considered for the Related pages menu.