Hide

YetaWF Documentation

Display
Print

Variable Substitution

YetaWF makes many variables available, such as Site Settings, current Page Settings, and much more. For example, the property pages for Site Settings and Page Settings display the variable names in the label's tooltip for each property listed (Show Variables must be enabled in User > Settings (standard YetaWF site) for the variable names to be shown).

These properties can be used through variable substitution, which are special tokens that will be replaced as a page is rendered by YetaWF.

Examples

[[Site,SiteDomain]]                ->  YetaWF.com
[[ThisPage,CanonicalUrlLink]]      ->  <link rel="canonical" href="https://yetawf.com/Documentation/YetaWF/Topic/g_doc_varsubst">
[[Manager,PageTitleHtml]]          ->  <title>Variable Substitution - YetaWF Documentation</title>
[[Env,SystemRoot]]                 ->  C:\Windows

There are different types of tokens using [ ], [[ ]], and {{ }} delimiters, which are used in different areas of YetaWF.

Syntax

[[object,property]]
[[object,property,subproperty]]

This token can be embedded in skins, can be part of views, partial views, etc. There are no restrictions. As long as the token becomes part of the generated HTML, it will be substituted. The substituted text is HTML encoded. If -property is specified (i.e., preceded by a dash), the substituted text is not HTML encoded. If -object is specified (i.e., preceded by a dash), the token is not substituted but rendered as-is, without the dash.

Syntax

{{object,property}}
{{object,property,subproperty}}

This token can be embedded in skins, can be part of views, partial views, Text Module contents, etc. but will only be substituted in Site View Mode. In Site Edit Mode the token is not substituted. This token type can be used with the Text Module in its contents for substitution in Site View Mode only. The substituted text is HTML encoded. If -property is specified (i.e., preceded by a dash), the substituted text is not HTML encoded. If -object is specified (i.e., preceded by a dash), the token is not substituted but rendered as-is, without the dash.

The following tokens can also be used within custom code using the YetaWF.Core.Support.Variables class.

Syntax

[object,property]
[object,property,subproperty]
{object,property}
{object,property,subproperty}

The DoubleEscape and CurlyBraces properties of the YetaWF.Core.Support.Variables class define how these are substituted. The substituted text is HTML encoded. If -property is specified (i.e., preceded by a dash), the substituted text is not HTML encoded. If -object is specified (i.e., preceded by a dash), the token is not substituted but rendered as-is, without the dash.

The following objects are available:

ObjectClassDescription
ThisPagePageDefinition objectAccesses the current page's Page Settings (YetaWF.Core.Pages.PageDefinition class) if available and replaces the token with the specified property value. subproperty is optional.
SiteSiteDefinition objectAccesses the current site's Site Settings (YetaWF.Core.Site.SiteDefinition class) and replaces the token with the specified property value. subproperty is optional.
PageOrSitePageDefinition object
SiteDefinition object
Accesses the current page's Page Settings (YetaWF.Core.Pages.PageDefinition class), and if not available, the site's Site Settings (YetaWF.Core.Site.SiteDefinition class) and replaces the token with the specified property value. subproperty is optional.
ManagerYetaWFManager objectAccesses the current Manager information (YetaWF.Core.Support.YetaWFManager class) if available and replaces the token with the specified property value. subproperty is optional.
GlobalsGlobals objectAccesses the Globals object (YetaWF.Core.Globals class) and replaces the token with the specified property value. subproperty is optional.
HttpRequestHttpRequest objectAccesses the HttpRequest object (System.Web.HttpRequest class) of the current request (if any) and replaces the token with the specified property value. subproperty is optional.
QueryStringQueryString objectAccesses the current Url's query string (if any) and replaces the token with the specified property value. subproperty is not available.
SessionSession objectAccesses the current site session object (YetaWF.Core.Support.Repository.SessionSettings class) if any and replaces the token with the specified property value. subproperty is not available.
Varanonymous objectUsed in applications which can pass an object to the YetaWF.Core.Support.Variables constructor (parms) to use variable substitution.
EnvstringUses the specified environment variable and replaces the token with the specified environment variable value. subproperty is not available.