These variables connect your templates to the API
ProcessWire provides these variables to every template, and any application bootstrapping it's API. These consist of the following variables outlined below. Click any one of them for detailed usage information.
The $page variable is provided to every template, and it contains all the fields specific to the page being viewed. This includes both built-in fields, which are common to all pages, as well as the custom fields.
While the $page variable holds the current page, the $pages variable is where you can get at all the other pages in your site. It includes functions for getting, finding, saving and deleting pages.
The $input variable is your connection to GET, POST and COOKIE variables, as well as URL segments and page numbers. It provides this with $input->get, $input->post, $input->cookie, $input->urlSegment(n) and $input->pageNum. While you can certainly use PHP’s superglobal versions for GET, POST and COOKIE vars, $input provides several benefits…
These functions are provided to fill the most common data sanitization needs with sites developed in ProcessWire. Always sanitize and/or filter any data you get from the user.
This API variable provides access to read and write session variables, login and logout users, and redirect to another page.
$fields is an API variable that contains all the custom page fields in your site. It provides the API functions available in the admin control panel under Setup > Fields. Use it to retrieve, save or delete custom page fields.
The $user API variable is your connection to the current user viewing the page.
The $log API variable enables you to create, manage and filter log entries.
The $templates API variable provides access to all of your site’s templates. Use the $templates API variable to retrieve, modify, create or delete templates and control what fields are attached to them. On this page, we’ll cover both the $templates API variable, as well as properties and methods common to individual templates.
The $config API variable contains all the settings specific to your site’s configuration. This includes URLs and paths, database configuration, session configuration, and more.
No comments yet. Be the first to post!
Your e-mail is kept confidential and not included with your comment. Website is optional.