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 ➡️
-
.NameCurrent platform name is: Oqtane -
.TypeCurrent platform type is: Oqtane -
.VersionCurrent 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 ➡️
-
.CurrentCodeCurrent code culture is: en-us -
.DefaultCodeen-us
With this object you can get general informtion about the current site.
On the new RazorPro it's on MyContext.Site.
⬇️ Result | Source ➡️
-
.Idof the current site (same asPortalIdin DNN): 13 -
.UrlThe site url with protocol: https://oqt-apps-dev.2sxc.org/razortutorial12 -
.UrlRootThe 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 ➡️
-
.Idof the current page: 288 (TabIdin DNN orPage.PageIdin oqtane.) -
.Urlthe page url with protocol: https://oqt-apps-dev.2sxc.org/razortutorial12 -
.Parametersall the url parameters of the pageauthorId=46285&tut=code-context&view1=whatever -
.Parameters[name]Access a specific parameter (in this case the parameterc140from the url)
Get information about the module context the code is running in.
On the new RazorTyped it's on MyContext.Module.
⬇️ Result | Source ➡️
-
.Idof 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 ➡️
-
.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 supe-user)
Get information about the view context.
On the new RazorTyped it's on MyView or on MyContext.View.
⬇️ Result | Source ➡️
-
.Idof the current view: 47382 -
.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: