Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
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

...

languagephp
linenumberstrue

...

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
languagephp
linenumberstrue
$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
languagephp
linenumberstrue
$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/TypeNameDescriptionDefault

Scope

url_shortenerdomain n/aSCGU