Go to main content

Permlink

Contents

Syntax

<txp:permlink>

The permlink can be used as a single tag or a container tag to return the permanent URL of the article being displayed.

If used as a container tag, the HTML required to output a hyperlink is returned; if used as a single tag, only the URL itself is returned.

Attributes

Tag will accept the following attributes (case-sensitive) as well as the global attributes :

context="list"
Specifies Textpattern parameters that must be “inherited” by the article URL. For example, when used in a list article form on a category page index.php?c=somecat, <txp:permlink /> without context attribute will produce canonical .../title links, while <txp:permlink context /> produces .../title?c=somecat links. Useful jointly with link_to_next/prev tags in individual article forms when one needs to restrain navigation to the current article category (author, month, …).
Default: unset.
id="integer"
Specifies the article id, assigned at creation of the article, to link. Can be found on the Articles panel.
Default: unset (current article).
style="style rule"
Inline CSS style rule. It’s recommended that you assign CSS rules via the class attribute instead.
Default: unset.
title="text"
HTML title attribute.
Default: unset.

Common global attributes

These attributes are shared by all tags - and plugins, provided they do not override the functionality.

break="value"
Where value is an HTML element, specified without brackets (e.g. break="li") or some string to separate list items.
Default: br (see break cross-reference).
breakby="integer(s)"
Used to group list items when separating by break. Possible values are lists of integers, like 2 (groups of 2 items) or 1,2 (alternate groups of 1 and 2 items). Otherwise, the value is evaluated on each loop and `break` happens as soon as it changes. Note that `string` must be enclosed in *double* quotes.
Default: 1 (unset) (see breakby cross-reference).
breakform="form name"
A form to be used as `break`, generally jointly with `breakby` attribute. The special `<+>` pattern in this form will be replaced with the list "chunk" accumulated when break happens.
Default: unset (see breakform cross-reference).
class="class name"
HTML class to apply to the wrapper.
Values: Any valid string.
Default: unset.
default="value"
The value to display if the tag's output is blank.
Values: Any.
Default: unset.
escape="list, of, transforms"
The transforms to apply to the output. See tag escaping for details.
Values: html, js, json, url, float, integer, number, ordinal, spell, lower, upper, title, [r|l]trim, quote, tags, textile, _any tag_
Default: html.
evaluate="number list"
Alter the processing order of top-level tags inside a form/container. Tags are normally executed from top to bottom. If you wish to change this order, imagine Textpattern tags are numbered incrementally from 1 inside a container. To process tags 3 and 5 first, then 1, 2, and 4, specify evaluate="3, 5" in your container tag.
Values: Any comma-separated numbers corresponding with the numerical position of primary (top-level) tags inside the container.
Default: unset.
html_id="value"
HTML id to apply to the wrapper.
Values: Any valid string.
Default: unset.
label="value"
The label to display before the output.
Values: Any valid string.
Default: unset.
labeltag="tag"
The tag (without angle brackets) to wrap the label.
Values: Any valid HTML tag, e.g. h3 or div.
Default: unset.
not="boolean"
Switch parts.
Values: 0 (no) or 1 (yes).
Default: unset (0).
replace="string"
Replace the content stripped via the trim attribute.
Values: Any valid string.
Default: unset.
trim="string or regex"
Remove the matching patterns from the output.
Values: Any. Use /value/ to trigger regular expression matching, otherwise the value will be treated verbatim as a set of characters to trim.
Default: unset.
wrapform="form name"
The form to be used as wraptag. Handy if the wraptag pattern is too long, or is reused.
Values: Any defined form name.
Default: unset.
wraptag="tag or pattern"
The tag (without angle brackets) to wrap the output.
Values: HTML tag or a string containing <+> pattern that will be replaced by the output.
Default: unset.

Examples

Example 1: Single tag

<txp:permlink />

This would result in something like:

bc. https://example.com/index.php?id=2

Example 2: Container tag

<txp:permlink>
    <txp:title />
</txp:permlink>

This would result in the following:

<a rel="bookmark" href="https://example.com/index.php?id=2">Article title</a>

Other tags used: title.

<txp:permlink class="awesome-article">
    <txp:title />
</txp:permlink>

By default <txp:permlink /> returns only a very basic link, which doesn’t allow for customising the link title, or adding a CSS class, etc. Using the tag in its single tag capacity opens up a lot more possibilities.

For example, to give the permanent link an HTML title attribute of the article’s title, and also apply a class to it:

<a class="awesome-article" href="<txp:permlink />">
    <txp:title />
</a>

Other tags used: title.

Genealogy

Version 4.7.2

context attribute added.

If you notice any kind of problem with this page's construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)