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 ➡️
-
.Name
Current platform name is: Oqtane -
.Type
Current platform type is: Oqtane -
.Version
Current platform version is: 5.1.2
With this object you can get general information about the culture.
⬇️ Result | Source ➡️
-
.CurrentCode
Current code culture is: en-us -
.DefaultCode
en-us
With this object you can get general informtion about the current site.
⬇️ Result | Source ➡️
-
.Id
of the current site (same asPortalId
in DNN): 2 -
.Url
The site url with protocol: https://blazor-cms.org/oqtane-tutorials -
.UrlRoot
The 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 ➡️
-
.Id
of the current page: 37 (TabId
in DNN orPage.PageId
in oqtane.) -
.Url
the page url with protocol: https://blazor-cms.org/oqtane-tutorials -
.Parameters
all the url parameters of the pagetut=code-context&variant=strong
-
.Parameters[name]
Access a specific parameter (in this case the parameterc140
from the url)
Get information about the module context the code is running in.
⬇️ Result | Source ➡️
-
.Id
of the current module: 103 -
.Id
of the current block: 0
.Guid
of the current block:
00000000-0000-0000-0000-000000000000 -
.Id
of the module-block: 0
.Guid
of 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 ➡️
-
.Id
of the current user: -1 -
.IsSiteAdmin
False (check if the current user is a site admin) -
.IsContentAdmin
False (check if the current user can edit content) -
.IsSystemAdmin
False (check if the current user is a super-user)
Get information about the view context.
⬇️ Result | Source ➡️
-
.Id
of the current view: 6437 -
.Edition
of the current view: (Get information about the edition used or return an empty string) -
.Identifier
of 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: -
.Name
of 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: