url
Defines a pattern from which relative URLs can be generated.
The pattern is used to generate URLs for content items of the type
represented by this element's parent
content-type
. By default, the final component
of a content item's URL is generated from the content item's id,
prefixed by the string article
and followed
by the suffix .ece
- for example:
article1234.ece
You can use this element to specify a pattern from which more meaningful URLs (sometimes called "pretty" URLs) can be generated.
The pattern must be specified as a combination of literal characters and the following placeholders:
{d}
-
Replaced by the content item's publication day of the month, in the format 1,2,...9,10 etc.
{dd}
-
Replaced by the content item's publication day of the month, in the format 01,02,...09,10 etc.
{MM}
-
Replaced by the content item's publication month, in the format 01,02,...12.
{MMM}
-
Replaced by the content item's publication month, in the format Jan, Feb, etc. The language of the month names used are determined by the
locale
attribute (if specified). {MMMM}
-
Replaced by the content item's publication month, in the format January, February, etc. The language of the month names used are determined by the
locale
attribute (if specified). {YY}
-
Replaced by the content item's publication year, in the format in the format 01,02, etc.
{YYYY}
-
Replaced by the content item's publication year, in the format in the format 2001,2002, etc.
{field.
name}
-
Replaced by the content of the content item field specified with name. The specified field must have a
mime-type
oftext/plain
. Any spaces in the field content are replaced by the character specified with thewhite-space-replacement
attribute. If this attribute is not specified, then any white spaces are replaced by_
(underscore) characters. Any multibyte Unicode characters are automatically URL-encoded. {id}
-
Replaced by the content item's id.
{counter}
-
Replaced by an integer counter used to distinguish otherwise identical URLs from one another. Note that a counter will always be appended to otherwise identical URLs even if you do not use this placeholder. Using this placeholder just lets you control the position of the counter if you do not want it to appear at the end of the URL.
{random}
-
Replaced by a random string used to allow the url of an article to change whenever the article is changed.
If you want to use multibyte Unicode characters or other special characters in the literal parts of your URL pattern, then you must enter them as URL-encoded strings - the will not encode them for you.
The Content Engine cannot generate URLs with more than 255
characters. If your URL pattern results in a URL that is longer than
this limit, then the last
{field.
name}
in the pattern will be truncated to fit the limit. Using field
content in URL patterns can easily result in very long URLs if the
fields contain multi-byte Unicode characters, as each byte is
converted to a three-character sequence. A single 3-byte character,
for example, will result in a 9-character URL sequence.
Syntax
<url locale="..."? white-space-replacement="..."? > text </url>
Examples
This example defines the structure of the URL generated for content items of the type defined by the
url
element's parentcontent-type
. It will generate the following relative URL for a content item with the title "Pretty URL" and a publication date of 30.05.2012:2012/05/30/article1231875438.ece/Pretty_URL
<url>{yyyy}/{MM}/{dd}/article{id}.ece/{field.title}</url>
This example will generate the following relative URL for a content item with the title "The story title" and a publication date of 30.05.2012:
2012/05/30/The-story-title-1231875438.ece
<url white-space-replacement="-">{yyyy}/{MM}/{dd}/{field.title}-{id}.ece</url>
Attributes
locale="
..."
(optional)-
Specifies the locale to use for formatting the URL. The locale setting only affects
{MMM}
and{MMMM}
placeholders. The locale specification is a string of the form:language or language
_
region or language_
region_
variantwhere:
- language
-
is a valid ISO language code. These codes are lower-case, two-letter codes as defined by ISO-639 - for example:
en
,no
,zh
,de
,sv
. - country
-
is a valid ISO country code. These codes are upper-case, two-letter codes as defined by ISO-639 - for example:
GB
,US
,DE
,SE
. - variant
-
is a vendor or browser-specific code. For example, use
WIN
for Windows,MAC
for Macintosh, andPOSIX
for POSIX.
For more detailed information, see the documentation of the Java Locale class.
white-space-replacement="
..."
(optional)-
Specifies a character or sequence of characters to be used to replace white space sequences in the generated URL, for example
-
or_
. If this attribute is not specified then_
is used as a replacement character by default. Note that the specified character(s) are only used to replace white space inside fields specified with the{field.
name}
placeholder.