ProcessWire functions
Documentation for procedural functions available in ProcessWire CMS.
Translation
Provides GetText-like language translation functions to Process
| Name | Return | Summary | |
|---|---|---|---|
__() __($text) __($text, $textdomain = null, $context = '') | string array | Perform a language translation | |
_n() _n(string $textSingular, string $textPlural, int $count) _n(string $textSingular, string $textPlural, int $count, string $textdomain = null) | string | Perform a language translation with singular and plural versions | |
_x() _x(string $text, string $context) _x(string $text, string $context, string $textdomain = null) | string | Perform a language translation in a specific context | |
wireLangEntityEncode() wireLangEntityEncode() wireLangEntityEncode($value = '') | bool int string null | Set entity encoding state for language translation function calls | |
wireLangReplacements() wireLangReplacements(array $values) wireLangReplacements(array $values) | array string | Set global translation replacement values | |
wireLangTranslations() wireLangTranslations() wireLangTranslations(array $values = array) | array | Set predefined fallback translation values |
Functions API
Provides an alternative to the API variables by providing functions of the same name, with these benefits:
- They are always in scope whether inside a function or outside of it.
- They are self documenting with your IDE, unlike API $variables.
- They cannot be accidentally overwritten the way variables can be.
- They provider greater contrast between what are API-calls and variables.
- In some cases it makes for shorter API calls.
- Some of the functions provide arguments for useful shortcuts.
These functions always refer to the current Process If these functions are not working for you, you can enable them by setting
Regardless of whether the Functions API is enabled or not, you can also access
any of these functions by prefixing the word $config->useFunctionsAPI=true; in your /site/config.php file. wire to them and using the format
wireFunction() i.e. wirePages(), wireUser(), etc. Or, if you do not
| Name | Return | Summary | |
|---|---|---|---|
cache() cache() cache(string $name = '', $expire = null, $func = null) | WireCache string array PageArray null | Get and save caches ($cache API variable as a function) | |
config() config() config(string $key = '', null $value = null) | Config mixed | Access a Process | |
database() database() database() | WireDatabasePDO | Create and execute PDO database queries ($database API variable as a function) | |
datetime() datetime() datetime(string $format = '', $value = '') | WireDateTime string int | Access date and time related tools ($datetime API variable as a function) | |
fields() fields() fields(string $name = '') | Fields Field null | Get or save fields independent of templates ($fields API variable as as function) | |
fieldtypes() fieldtypes() fieldtypes(string $name = '') | Fieldtypes Fieldtype null | Get Fieldtypes ($fieldtypes API variable as a function) | |
files() files() files() | WireFileTools | Access tools for working on the file system ($files API variable as a function) | |
input() input() input(string $type = '', string $key = '', string $sanitizer = null, $fallback = null) | WireInput WireInputData array string int null | Access GET, POST or COOKIE input variables and more ($input API variable as a function) | |
languages() languages() languages($name = '') | Languages Language NullPage null | Access all installed languages in multi-language environment ($languages API variable as a function) | |
modules() modules() modules(string $name = '') | Modules Module ConfigurableModule null | Get a module, get module information, and much more ($modules API variable as a function) | |
page() page() page(string $key = '', null $value = null) | Page mixed | Returns the current Page being viewed ($page API variable as a function) | |
pageId() pageId($value) pageId($value) | int false | Return id for given page or false if it’s not a page | |
pages() pages() pages($selector = '') | Pages PageArray Page NullPage | Retrieve or save pages ($pages API variable as a function) | |
paths() paths() paths(string $key = '') | null Paths string | Get one of any named server disk paths (shortcut to the $config API variable “paths” property) | |
permissions() permissions() permissions($selector = '') | Permissions Permission PageArray null NullPage | Get, find or save permissions ($permissions API variable as a function) | |
region() region() region(string $key = '', $value = null) | string null bool array | Get or set an output region (primarily for front-end output usage) | |
roles() roles() roles($selector = '') | Roles Role PageArray null NullPage | Get, find or save roles ($roles API variable as a function) | |
sanitizer() sanitizer() sanitizer(string $name = '', string $value = '') | Sanitizer string int array null mixed | Sanitize variables and related string functions ($sanitizer API variable as a function) | |
session() session() session(string $key = '', null $value = null) | Session null string array int float | Get or set values in the current user session ($session API variable as a function) | |
setting() setting() setting($name = '', $value = null) | array string int bool mixed null | Get or set a runtime site setting | |
templates() templates() templates(string $name = '') | Templates Template null | Get or save templates ($templates API variable as a function) | |
urls() urls() urls(string $key = '') | null Paths string | Get one of any named system URLs (shortcut to the $config API variable “urls” property) | |
user() user() user(string $key = '', null $value = null) | User mixed | Get the currently logged in user ($user API variable as a function) | |
users() users() users($selector = '') | Users PageArray User mixed | Get, find or save users ($users API variable as a function) |
API reference based on Process