Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Requirements
Resources
Work with the Context (Page, Site, etc.)
Whenever you need to know about the current environment, you need Context information. These are the contexts you should know about:
- Platform
- Site
- Page
- Module
- View
- User
With the ICmsContext object you can get general information about the current platform.
⬇️ Result | Source ➡️
-
.NameCurrent platform name is: Oqtane -
.TypeCurrent platform type is: Oqtane -
.VersionCurrent platform version is: 5.1.2
With this object you can get general information about the culture.
⬇️ Result | Source ➡️
-
.CurrentCodeCurrent code culture is: en-us -
.DefaultCodeen-us
With this object you can get general informtion about the current site.
⬇️ Result | Source ➡️
-
.Idof the current site (same asPortalIdin DNN): 2 -
.UrlThe site url with protocol: https://blazor-cms.org/oqtane-tutorials -
.UrlRootThe site url without a protocol: blazor-cms.org/oqtane-tutorials
Get information about the page which is the contxt for the currently running code.
⬇️ Result | Source ➡️
-
.Idof the current page: 37 (TabIdin DNN orPage.PageIdin oqtane.) -
.Urlthe page url with protocol: https://blazor-cms.org/oqtane-tutorials -
.Parametersall the url parameters of the pageblade=page&tut=code-context&variant=strong -
.Parameters[name]Access a specific parameter (in this case the parameterc140from the url)
Get information about the module context the code is running in.
⬇️ Result | Source ➡️
-
.Idof the current module: 103 -
.Idof the current block: 0
.Guidof the current block:
00000000-0000-0000-0000-000000000000 -
.Idof the module-block: 0
.Guidof the current module-block:
00000000-0000-0000-0000-000000000000
Note: in most cases the Block.Id and Module.Block.Id are the same, but in some cases they are different. For example when using inner-content (blocks in blocks).
Get information about the user which is currently used by the code.
⬇️ Result | Source ➡️
-
.Idof the current user: -1 -
.IsSiteAdminFalse (check if the current user is a site admin) -
.IsContentAdminFalse (check if the current user can edit content) -
.IsSystemAdminFalse (check if the current user is a super-user)
Get information about the view context.
⬇️ Result | Source ➡️
-
.Idof the current view: 6437 -
.Editionof the current view: (Get information about the edition used or return an empty string) -
.Identifierof the view:
An optional identifier which the View configuration can provide. Use this when you want to use the same template but make minor changes based on the View selected (like change the number of columns). Usually you will use either this OR the Settings: -
.Nameof the viewDefault Tutorial Page (new v16)
Name of the view as configured - note that because of i18n it could be different depending on the language. To clearly identify a view, use the Identifier or use Settings: