Excerpt |
---|
Url shortener plugin shows overview and information The UrlShortener plugin provides an overview of all configured short url's and alows you to edit or remove short url'sdefined short URLs for articles and allows for editing or deleting them. |
Example
...
language | php |
---|---|
linenumbers | true |
...
API
This plugin offers the classes cApiShortUrlCollection and cApiShortUrl which allow for creating and validating short URIs.
Create a short URI
The class cApiShortUrlCollection offers the method create() which expects at least a short URI which is given as first parameter $uri. The latter parameters ($idart, $idlang, $idclient) are optional and are taken from cRegistry (getArticleId(), getLanguageId() and getClientId() respectivly) if not set.
Code Block | ||||
---|---|---|---|---|
| ||||
$coll = new cApiShortUrlCollection(); /** @var cApiShortUrl */ $item = $coll->create($uri, $idart, $idlang, $idclient); // validate short uri $shortUrlItem->isValidShortUrl($myShortUri); |
...
Validate a short URI
In order to check if an URI is a valid short URI you can use the collections method isValidShortUrl() which expects an URI as single parameter. The check will be performed with the following criteria:
- given url is not a directory in the client folder
- given url respects minimum length
- given url contains only valid characters
- given url is not an article or category alias
Code Block | ||||
---|---|---|---|---|
| ||||
$coll = new cApiShortUrlCollection();
$coll->isValidShortUrl($uri); |
This method returns either true or an errorcode:
- cApiShortUrlCollection::ERR_IS_CLIENT_FOLDER
- cApiShortUrlCollection::ERR_TOO_SHORT
- cApiShortUrlCollection::ERR_INVALID_CHARS
- cApiShortUrlCollection::ERR_IS_ARTICLE_ALIAS
Settings
Area/Type | Name | Description | Default | Scope |
---|---|---|---|---|
url_shortener | domain | n/a | SCGU |