Link Handler
The link handler will produce a link. It uses a combination of the content of the tag and options to produce the link. In all cases, if provided, the content of the tag will become the content of the link.
The handler is implemented by the LinkHandler class and initialized via the XML Configured Processor.
For example:
becomes: /index.html
The handler understands the difference between internal (to a site) links and external links. If no content is given for the link then the options are used for the url and link content instead.
The init element can optionally contain one or more src elements (see shortcuts).
Example:
The shortcuts are defined in the init element. The shortcut is defined by using a src element, two attributes id and url are required, the id attribute defines the short name for the shortcut and the url defines the url that it maps to.
Example:
There is no limit to the number of shortcuts that can be defined. Shortcut names are case-sensitive.
The handler is implemented by the LinkHandler class and initialized via the XML Configured Processor.
For example:
[link]/index.html[link]
The handler understands the difference between internal (to a site) links and external links. If no content is given for the link then the options are used for the url and link content instead.
Handler Options
The handler supports the following options:Name | Optional | Type | Description |
url | Yes | Any value | If provided this will be the url for the link. |
1 | Yes | Any value | If no url option is provided but an anonymous option is provided then this will be used as the link url. |
XML Initialization
The init element should contain a templates element that should then contain an internalWrapper element and an externalWrapper element. The internalWrapper template will be used for links internal to the site (those that have a url that does not start with http://). The externalWrapper template will be used for links external to the site, i.e. those that start with http:// or https://.The init element can optionally contain one or more src elements (see shortcuts).
Example:
<init> <src id="polliwog" url="http://polliwog.sourceforge.net" /> <src id="josql" url="http://josql.sourceforge.net/" /> <templates> <externalWrapper><[CDATA[<span><a title="External site, opens in new window" target="_blank" href="[[VALUE]]" [[OPTIONS]] Class="link"><img alt="External site, opens in new window" src="imgs/extlink.gif" border="0" /> [[NAME]]</a></span>]]></externalWrapper> <internalWrapper><[CDATA[<a href="[[VALUE]]" [[OPTIONS]] Class="link">[[NAME]]</a>]]></internalWrapper> </templates> </init>
Shortcuts
To make referencing urls easier the handler supports shortcuts. This is basically a short name that maps to a url prefix (or a full url).The shortcuts are defined in the init element. The shortcut is defined by using a src element, two attributes id and url are required, the id attribute defines the short name for the shortcut and the url defines the url that it maps to.
Example:
[link hoglet,index.html/]
Example Usage
- A link that has content and an anonymous option as the url.Would produce: Home Page
[link index.html]Home Page[link]
- A link that has no content and an anonymous option as the url.Would produce: index.html
[link index.html/]
- An external link that has content and uses option: url.Would produce: Google.com
[link url=http://www.google.com]Google.com[link]