$urlsshort()

Convert any path, URL or filename to a URL from installation root

  • This excludes subdirectories prior to installation root (whether URL, path or file).
  • It will accept a predefined path/url name, a path/directory, or a file path/url
  • This is not meant to be used with http[key]
  • This is useful in human readable notifications or text where directories prior to installation root might be irrelevant or redundant to the information presented.

Available since version 3.0.258.

Example

echo $config->paths->site;          // /home/ryan/public_html/processwire.com/site/
echo $config->paths->short('site'); // /site/
echo $config->urls->site;           // /processwire.com/site/
echo $config->urls->short('site');  // /site/

$file = __DIR__ . '/Paths.php';     // /home/ryan/public_html/processwire.com/wire/core/Paths.php
echo $config->paths->short($file);  // /wire/core/Paths.php

$url = $config->urls->templates;    // /processwire.com/site/templates/
echo $config->urls->short($url);    // /site/templates/

Usage

$string = $urls->short(string $key);

Arguments

NameType(s)Description
$keystring

Name of path/url to use, or specify an actual path/url to shorten it.

Return value

string

Exceptions

Method can throw exceptions on error:

  • WireException - if used with 'http' prefixed key


$urls methods and properties

API reference based on ProcessWire core version 3.0.259