PagesSortfields::encode()

Encodes a sortfield from a fieldname to a signed integer (ID) representing a custom field, or native field name

The returned value will be a negative value (or string preceded by a dash) if the sortfield is reversed.

Usage

// basic usage
$string = $pagesSortfields->encode(string $sortfield);

// usage with all arguments
$string = $pagesSortfields->encode(string $sortfield, string $default = 'sort');

Arguments

NameType(s)Description
$sortfieldstring
$default (optional)string

Default sortfield name Default:'sort'

Return value

string int


PagesSortfields methods and properties

API reference based on ProcessWire core version 3.0.251