FieldtypeURL
Stores a URL — local/relative or absolute. Extends FieldtypeText.
string — a valid URL, or empty string '' when blank.
// Get
$page->url_field // string, e.g. "https://example.com/path/"
// Set
$page->url_field = 'https://example.com/path/';
$page->url_field = '/local/path/'; // relative URL (if allowed by field setting)
$page->url_field = ''; // clear
$page->save('url_field');Values are sanitized through $sanitizer->url() — dangerous URL schemes (e.g. javascript:) are
stripped to blank, but arbitrary non-URL strings are passed through as-is. Validate URL format
separately if your use case requires it.
$pages->find('url_field=""'); // no URL
$pages->find('url_field^=https://'); // starts with
$pages->find('url_field*=example.com'); // contains// With TextformatterEntities applied and output formatting ON:
echo '<a href="' . $page->url_field . '">Link</a>';If the addRoot field setting is enabled, relative URLs (starting with /) are automatically
prepended with the site's root path when output formatting is on.
noRelative=1disables relative/local URLs; only full protocol URLs are accepted.allowIDN=1permits internationalized domain names.allowQuotes=1allows quote characters in URLs (always entity-encode output when used).addRoot=1prepends the site's root path to relative URLs during output formatting — useful for subdirectory installs.- Strongly recommended: apply
TextformatterEntitiesto any URL field used in HTML output. - Database column:
text NOT NULL(inherits fromFieldtypeText). - Compatible fieldtypes: any fieldtype extending
FieldtypeText.
For documentation about the fields used in this class, please see: wire/core/Fieldtype.php
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Fieldtype class also inherits all the methods and properties of: FieldtypeText, Fieldtype, WireData and Wire.
Common
| Name | Return | Summary | |
|---|---|---|---|
Fieldtype Fieldtype Fieldtype | string | Format value | |
Fieldtype Fieldtype Fieldtype | InputfieldWrapper | Get field configuration Inputfields | |
Fieldtype Fieldtype Fieldtype | string | Get the Field class to use for fields of this type | |
Fieldtype Fieldtype Fieldtype | Inputfield InputfieldURL | Get Inputfield | |
Fieldtype Fieldtype Fieldtype | string | Sanitize value for storage |
Additional methods and properties
In addition to the methods and properties above, Fieldtype
API reference based on ProcessWire core version 3.0.261