This plugin provides a new tag, <txp:adi_link />, which will output links from various sources, with custom attributes.
adi_link can be used as follows:
<txp:adi_link /><txp:adi_link> ... </txp:adi_link>in:
Simple link:
<txp:adi_link url="http://www.example.com/" />
- creates link to “http://www.example.com/”, with link text of “www.example.com”
External link:
<txp:adi_link url="www.example.com" ext_link="1"/>
- creates link with HTML attributes: class=“ext_link” & rel=“external”
Link using URL from another source:
<txp:adi_link><txp:custom_field name="link"/></txp:adi_link>
- creates a link from URL stored in a custom field called “link”
Enhance links in an article:
notextile. <txp:adi_link ext_link="1">
* "Link 1":http://www.linkone.com * "Link 2":http://www.linktwo.com * "Link 3":http://www.linkthree.com
notextile. </txp:adi_link>
Note: separate adi_link tags from content with blank lines & use “notextile” to prevent empty <p></p> being generated.
TXP link:
<txp:adi_link id="23" link_text="New text"/>
- outputs a specific TXP link, overriding the stored link text/title
In a link form:
<txp:adi_link class="myclass" />
- when used in a Link Form, will output link with class of “myclass”
Link to page anchor:
<txp:adi_link anchor="top" link_text="back to top" />
- outputs a link to #top on current page
Link to section with additional URL vars:
<txp:adi_link section="mysection" urlvars="var1=value1&var2=value2" link_text="My Section with extras" />
- outputs a link to section “mysection”, with extra URL vars appended
html_id="html id"
- the HTML ID applied to the link. Default = “” (no ID).
class="class name"
- CSS class applied to the link. Default = “” (no class).
url="url"
- URL (with or without “http://” prefix) used for link. Default = “” (URL taken from some other source).
link_text="text"
- text to be used for link. Default = “” (use URL). Will override value from database when used with TXP link id.
title="text"
- text to be used for HTML title attribute. Default = “” (use link text).
pretty_url="boolean"
- strip “http://” prefix & trailing slash from URL. Default = “1” (Yes). For use when link_text attribute not specified.
ext_link="boolean"
- specifies whether the link should be rendered as an “external” link or not – see ext_class & rel_name. Default = “0” (No).
ext_class="class name"
- CSS class applied to the link if ext_link=1. Default = “ext_link”.
rel_name="rel name"
- value for the HTML rel attribute. Default = “bookmark” (or “external” if ext_link=“1”).
escape="html"
- escape HTML entities in link text & link title. Default = “html” (Yes).
single_url="boolean"
- force single URL mode. Default = “0” (No). For use in container tag mode when enclosing a URL that doesn’t have “http://” prefix.
id="link ID number"
- display specific TXP link.
url_link_text="boolean"
- use URL for the link text. Default = “0” (No). For use with TXP links, as normally the stored link name/title is displayed.
suppress_href="boolean"
- suppress output of the href attribute. Default = “0” (No).
section="section name"
- output link to specified section. Default = not used. For current section, use section="".
anchor="page anchor"
- output link with page anchor. Default = “” (not used). If no URL or section specified then link to current page used.
urlvars="URL variables"
- append some URL vars. Default = “” (none). For example urlvars="var1=value1&var2=value2".
category="category name"
- output link with specified category. Default = “” (No category).
Support and further information can be obtained from the Textpattern support forum. A copy of this help is also available online. More adi_plugins can be found here.