#5 CmsContext.Module – ID, etc.
Requirements
Resources
Interface ICmsModule
Get information about the module context the code is running in.
On the new RazorPro
it's on MyContext.Module
.
On the older Razor14
or Razor12
it's on CmsContext.Module
.
Output
-
.Id
of the current module: 103
#5 CmsContext.Module – ID, 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 ICmsModule</h2> <p> Get information about the module context the code is running in. </p> <p>On the new <code>RazorPro</code> it's on <code>MyContext.Module</code>.</p> <p>On the older <code>Razor14</code> or <code>Razor12</code> it's on <code>CmsContext.Module</code>.</p> </div> </div> <ol> <li> <code>.Id</code> of the current module: <strong>@MyContext.Module.Id</strong> </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 module: <strong>@CmsContext.Module.Id</strong> </li> </ol> *@ @* Footer *@ @Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })