#7 CmsContext.View – ID, Identifier, Edition, Name, etc.
Requirements
Resources
Interface ICmsView
Get information about the view context.
On the new RazorPro
it's on MyView
or on MyContext.View
.
On the older Razor14
or Razor12
it's on CmsContext.View
.
Output
-
.Id
of the current view: 4671 -
.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 viewC170 View
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:
#7 CmsContext.View – ID, Identifier, Edition, Name, etc.
Source Code of this file
Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code
@inherits Custom.Hybrid.RazorTyped @using ToSic.Razor.Blade; <!-- unimportant stuff, hidden --> <div @Sys.PageParts.InfoWrapper()> @Html.Partial("../shared/DefaultInfoSection.cshtml") <div @Sys.PageParts.InfoIntro()> <h2>Interface ICmsView</h2> <p> Get information about the view context. </p> <p>On the new <code>RazorPro</code> it's on <code>MyView</code> or on <code>MyContext.View</code>.</p> <p>On the older <code>Razor14</code> or <code>Razor12</code> it's on <code>CmsContext.View</code>.</p> </div> </div> <ol> <li> <code>.Id</code> of the current view: <strong>@MyView.Id</strong> </li> <li> <code>.Edition</code> of the current view: <strong>@MyView.Edition</strong> (Get information about the edition used or return an empty string) </li> <li> <code>.Identifier</code> of the view: <strong>@MyView.Identifier</strong> <br> 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: </li> <li> <code>.Name</code> of the view <code>@MyView.Name</code> <br> 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: </li> </ol> @* Snippet for the old v14 code, which shouldn't run but should be shown. This is a bit of a hack, but it works <ol> <li> <code>.Id</code> of the current view: <strong>@CmsContext.View.Id</strong> </li> <li> <code>.Edition</code> of the current view: <strong>@CmsContext.View.Edition</strong> (Get information about the edition used or return an empty string) </li> <li> <code>.Identifier</code> of the view: <strong>@CmsContext.View.Identifier</strong> <br> 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: </li> <li> <code>.Name</code> of the view <code>@CmsContext.View.Name</code> <br> 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: </li> </ol> *@ @* Footer *@ @Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })