Who this is for. The theme developer who needs something the record does not carry: the query string, the visitor, a menu, a list of other records. Afterwards you will know which helper holds it, what it is called in your engine, and which ones can be missing.
Two kinds of variable
A template rendered for a page request receives two sets of variables. The controller's own, which depend on what it rendered (page and record for a page, post for a blog post; the full list), and the platform's common set below, which every front-end render gets. The names are the same in both engines: Smarty writes $_request, Twig _request.
PHP's superglobals are not among them. In Smarty, {$smarty.get.page}, {$smarty.server.HTTP_HOST} and their siblings fail to compile with (secure mode) super globals not permitted, and $_GET is an undefined variable. Twig has no way to reach them at all. The request, the cookies and the session are read through the helpers.
The common variables
| Variable | What it is | What you call on it |
|---|---|---|
_request | The current request | getPath(), getParameter(name), getParameters(), getQueryString(), getMethod(), getCookie(name, default), getCookies(), getHostname(), getScheme(), getSchemeAndHost(), getLocale(), getLanguage(), isPdfRequest() |
_response | The response being built | preventCaching(), enforceCaching(), setCacheTTL(seconds), setCacheExpiryDate(date), addCacheVaryParameter(name), setCacheVaryParameters(names), setCookie(name, value, expire, path), redirect(url, status), returnNotFound(), forceDownload(filename) |
_url | Paths built from route names | getPath(moduleRoute, controllerRoute, parameters), getFrontendPath(…), getModulePath(moduleRoute), hasPath(…), getCurrentPath(), isCurrentPath(path) |
_currentSite | The site and the environment serving the request | getId(), getName(), getHostname(), getPrimaryHostname(), getEnvironmentName(), isPrimaryEnvironment(), getLastVcsHash() |
_currentUser | Whoever is signed in, member or backend user | isLoggedIn(), isFrontendUser(), isBackendUser(), isAdmin(), isDeveloper(), getType(), getId(), getFullName(), getUsername(), getPerson() |
_siteData | Values editors keep under site data, without a deploy | get(key): the current site's value, else the client-wide one, else nothing |
_config | The site's settings | get('Module.setting'), has(key). A protected setting reads as *** |
_menu | Menus, by their exact admin name | get(name), nothing when no menu has that name |
_globalComponents | Global components, by identifier | get(identifier) |
_forms | Forms, by identifier | get(identifier) |
_query | Records the controller did not load | findBy(entity, criteria, orderBy, limit, offset), findOneBy(…), findCustomEntityRecordsBy(type, …), findCustomEntityRecordBy(type, …) |
_image | An image from the Files module, by path | get(path) |
_search | The Search module | search(view, parameters) |
_cart | The visitor's cart | getCart(), isIn(productCode), getItem(productCode) |
_messages | Messages queued for the visitor, such as a sign-out confirmation | hasMessages(type), getMessages(type), with success, warning or error |
_notifications | The signed-in user's notifications | getUnseenCount(), getNotifications() |
_templateContext | A store shared by every template of one render | set(key, value), get(key, default), all() |
_string | String helpers | slugify(text), camelToSlug(text), snakeToWords(text), getHtmlSafeJson(array) |
__ | The translator | translate(key, parameters, domain), setDefaultDomain(domain) |
_inlineScriptNonce | A string: the nonce every inline <script> needs | Print it in the nonce attribute |
_csrfToken | A string: the form security token. Only when someone is signed in | Print it in forms that post to the platform |
The table leaves out _widgets: widgets are deprecated, and a template reads records with the query helper _query instead. The helpers that look a record up by name or identifier answer with nothing when there is no match, rather than an error. A renamed menu or a mistyped form identifier therefore leaves that part of the page empty: test the result before using it.