User:Ferretwings/ShortLink

[ ]

This shortens the displayed text of external URL links. It is meant for mass output, e.g. via another template. In DPL it can be used in combination with and  in the output. It strips the "http://" and "www." prefixes from the displayed URL, and sets a URL text length limit. Note: Requires Extension:StringFunctions

Usage

 * url: required
 * Set the full URL http://...


 * len: optional; default: 35
 * The number of displayed characters. It returns the string without "http://" and "www." (if the URL is longer than the default 35 characters).


 * suffix: optional; default: "…" (not "...")
 * Adds a suffix at the end of the shortened string. It is not recommend to set an empty suffix.


 * plain: optional; default: no
 * Returns each link in a span with class=plainlinks. Note that you should have this set up in you CSS. Also note that your page code is more clear when you set class="plainlinks" for the element that contains all your links.


 * domainonly: optional; default: no
 * domainonly=yes will only display the domain (including subdomains if given). A setting for len is useless here.


 * domainbold: optional; default: no
 * domainbold=yes will display the domain in bold. This is useful for lists of many different external URLs. The prefix is also stripped for URLs shorter than len.

Examples
The URL (stripped: without "http://", "https://" and "www.") has 45 characters. That's more than len (default 35). Result:

The (stripped) URL is shorter than the len (default 35). It will be fully returned without suffix. Result:

We use a len of 50. Result:

We add a custom suffix and use class="plainlinks". Result:

* We highlight the domain. Result:

* We only want the domain. Since those are short it's useful to use plain=yes. Result:

The orginal template was copied from http://followthescore.org/dpldemo/Template:ShortLink

For practical examples see some Template:ShortLink/Examples|DPL output.

See also Template:Short.