DOM\CurrentContext
Templating
Global Functions
Website
\Components\Website\Designs \Components\Website\Media \Components\Website\Pages \Components\Website\Pages\Forms \Components\Website\Posts \Components\Website\Posts\Categories
Customers
\Components\Customers\Contacts \Components\Customers\Contacts\Relationships \Components\Customers\Contacts\Relationships\Types \Components\Customers\Groups
Marketing
\Components\Marketing\EmailMarketing \Components\Marketing\Events \Components\Marketing\Events\Attendees \Components\Marketing\Events\Categories \Components\Marketing\Events\Locations \Components\Marketing\SMSMarketing
Commerce
\Components\Commerce\Carts \Components\Commerce\Carts\Current \Components\Commerce\Discounts \Components\Commerce\Products \Components\Commerce\Products\Brands \Components\Commerce\Products\Categories \Components\Commerce\Products\Inventory \Components\Commerce\RecurringSales\Items \Components\Commerce\Sales \Components\Commerce\Sales\Items \Components\Commerce\Sales\Receipts \Components\Commerce\Sales\Receipts\Allocations
Settings
\Components\Settings\Administrators \Components\Settings\CustomFields \Components\Settings\Domains
Other Apps
\Components\Website\Comments \Components\Commerce\Affiliates \Components\Commerce\Affiliates\Administrators \Components\Commerce\Affiliates\Commissions \Components\Commerce\Affiliates\Payments \Components\Commerce\RecurringSales \Components\Commerce\RecurringSales\StoredCards
Framework
\Framework\Caching \Framework\Data\Util \Framework\DOM\CurrentContext
METHODS
\Framework\HTML\Converters \Framework\HTTP\Cookies \Framework\HTTP\Redirection \Framework\HTTP\Request \Framework\HTTP\Session \Framework\HTTP\UserAgent \Framework\I18N\CompanyTypes \Framework\I18N\Countries \Framework\I18N\Languages

CurrentContext

Provides an interface for accessing and managing the context of the current request.

This class manages template variables (the `$variable` syntax in `[? ... ?]` expressions), the document stack, entity context, and rendering mode flags such as email and edit mode.

It is the bridge between PHP components and the template/scripting layer — variables registered here become accessible in page and design templates.

Methods

Invoke via \Framework\DOM\CurrentContext::method()
Click a method name to copy it.
- ` array getAllVariables() `
Returns all variables currently registered in the rendering context as an associative array keyed by variable name.

This includes superglobals (`$_GET`, `$_POST`, etc.), variables set by components and controls, and any variables pushed onto the stack by data controls. Primarily used internally by the scripting engine to resolve `$variable` references in templates.
Return
array
- ` bool getIsInEditMode() `
Returns whether the current page is currently being edited in the HTMLEditor.

Use this in design templates to hide or simplify elements that interfere with the editing experience — such as popovers, sticky headers, live chat widgets, or heavy scripts — while preserving the overall look and feel of the design.

When true, the design (header/footer) is rendering behind the editor's striped overlay with limited client-side scripting.

The following example will not show the sticky-header 'in edit mode': <logic:if test="!\Framework\DOM\CurrentContext::getIsInEditMode()"> <div class="sticky-header">...</div> </logic:if>
Return
bool
- ` bool getIsInEmail() `
Returns whether the current page is being rendered as an email (e.g. a marketing email, form submission notification, or automation email).

When true, controls should adapt their output for email clients — avoiding JavaScript, complex CSS, and interactive elements. Many built-in controls already check this flag to switch to email-safe rendering (e.g. tables instead of flexbox, inline styles, and static fallbacks for rotators and videos).

The following example hides an interactive element when rendering inside an email: <logic:if test="!\Framework\DOM\CurrentContext::getIsInEmail()"> <div class="live-chat-widget">...</div> </logic:if>
Return
bool
- ` mixed getVariable($strVarName) `
Returns the value of a variable from the current rendering context.

This is the PHP equivalent of using `$variableName` in a `[? ... ?]` template expression.
It retrieves variables registered via setVariable() or setVariablePush(), including those set by data controls (e.g. `<data:table as="row">` makes `$row` available).

Returns null if the variable has not been registered.

The following example retrieves the current page variable from PHP: $arrPage = \Framework\DOM\CurrentContext::getVariable('page');
Parameters:
- $strVarName
mixed
Return
Value of the variable, or null if not set
- ` bool getVariableIsSet($strVarName) `
Returns whether a variable has been registered in the current rendering context.

Useful for checking if a variable exists before accessing it, particularly in controls or components that may operate in different contexts where a variable may not have been set.

The following example conditionally renders a greeting if the variable is available: <logic:if test="\Framework\DOM\CurrentContext::getVariableIsSet('greeting')"> <p>[? $greeting ?]</p> </logic:if>
Parameters:
- $strVarName
mixed
Return
bool
- ` void setVariable($strVarName, $mixedValue) `
Registers a variable into the current rendering context, making it accessible in templates via the `$variableName` syntax inside `[? ... ?]` expressions.

This is the primary way to pass data from PHP into the template layer.

Components and controls use this to expose data (e.g. the current contact, cart, or page entity) for use in designs and page templates.

The following example registers a variable and renders it in a template: \Framework\DOM\CurrentContext::setVariable('greeting', 'Hello World'); <p>[? $greeting ?]</p>
Parameters:
- $strVarName
mixed
- $mixedValue
mixed
- ` void setVariablePush($strVarName, $mixedValue) `
Registers a variable with stack-based scoping. The previous value (if any) is preserved on an internal stack and can be restored later with unsetVariablePop().

This is used by data controls and includes to temporarily override a variable within a nested scope. For example, `<data:table as="row">` pushes each row's data as `$row` during rendering, and pops it when the row is complete — ensuring outer variables with the same name are restored.

Use setVariable() instead when scoping is not needed.
Parameters:
- $strVarName
mixed
- $mixedValue
mixed
- ` void unsetVariable($strVarName) `
Removes a variable from the current rendering context entirely.

After calling this, the variable will no longer be accessible in templates. If the variable was registered with setVariablePush(), use unsetVariablePop() instead to restore the previous value.
Parameters:
- $strVarName
mixed
- ` void unsetVariablePop($strVarName) `
Restores a variable to its previous value after a setVariablePush() call.

If there is a previous value on the stack, it is restored. If the stack is empty, the variable is removed entirely. This is the counterpart to setVariablePush() and must be called in matching pairs to maintain correct scoping.
Parameters:
- $strVarName
mixed