App
Selected: Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
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.
On the new RazorTyped
it's on MyContext.Platform
.
⬇️ Result | Source ➡️
-
.Name
Current platform name is: Oqtane -
.Type
Current platform type is: Oqtane -
.Version
Current platform version is: 5.0.2
With this object you can get general information about the culture.
On the new RazorTyped
it's on MyContext.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.
On the new RazorPro
it's on MyContext.Site
.
⬇️ Result | Source ➡️
-
.Id
of the current site (same asPortalId
in DNN): 13 -
.Url
The site url with protocol: https://oqt-apps-dev.2sxc.org/razortutorial12 -
.UrlRoot
The site url without a protocol: oqt-apps-dev.2sxc.org/razortutorial12
Get information about the page which is the contxt for the currently running code.
On the new RazorTyped
it's on MyPage
or on MyContext.Page
.
⬇️ Result | Source ➡️
-
.Id
of the current page: 288 (TabId
in DNN orPage.PageId
in oqtane.) -
.Url
the page url with protocol: https://oqt-apps-dev.2sxc.org/razortutorial12 -
.Parameters
all the url parameters of the pageid=46284&tut=code-context&view1=whatever
-
.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.
On the new RazorTyped
it's on MyContext.Module
.
⬇️ Result | Source ➡️
-
.Id
of the current module: 352
Get information about the user which is currently used by the code.
On the new RazorTyped
it's on MyUser
or on MyContext.User
.
⬇️ 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 supe-user)
Get information about the view context.
On the new RazorTyped
it's on MyView
or on MyContext.View
.
⬇️ Result | Source ➡️
-
.Id
of the current view: 47382 -
.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: