Table of Contents

Interface ICmsView

Namespace
ToSic.Sxc.Context
Assembly
ToSic.Sxc.dll

View context information.

🪒 In Dynamic Razor it's found on CmsContext.View
🪒 In Typed Razor it's found on MyView

[PublicApi]
public interface ICmsView : IHasMetadata

Remarks

Added in 2sxc 12.02

Properties

Edition

Edition used - if any. Otherwise empty string.

🪒 Use in Razor: CmsContext.View.Edition
🪒 Use in Typed Razor: MyView.Edition

string Edition { get; }

Property Value

string

Folder

This is the preferred way to get the Url or Path to the current view.

This is different from the App.Folder, because it will also contain the edition (if there is an edition)

🪒 Use in Razor: CmsContext.View.Folder - like CmsContext.View.Folder.Url
🪒 Use in Typed Razor: MyView.Edition - like MyView.Folder.Url

IFolder Folder { get; }

Property Value

IFolder

Remarks

Added in v16.04

Id

View configuration ID

🪒 Use in Dynamic Razor: CmsContext.View.Id
🪒 Use in Typed Razor: MyView.Id

int Id { get; }

Property Value

int

Identifier

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

🪒 Use in Razor: CmsContext.View.Identifier
🪒 Use in Typed Razor: MyView.Identifier

string Identifier { get; }

Property Value

string

Metadata

Metadata of the current view

[JsonIgnore]
IMetadata Metadata { get; }

Property Value

IMetadata

Remarks

Added in v13.12

Name

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

🪒 Use in Dynamic Razor: CmsContext.View.Name
🪒 Use in Typed Razor: MyView.Name

string Name { get; }

Property Value

string

Resources

Settings of this view. This property only works in the new typed code.

Note that many views don't have their own settings, so this would be empty = null.

ITypedItem Resources { get; }

Property Value

ITypedItem

Remarks

Resources added to API in v17.04

Settings

Settings of this view. This property only works in the new typed code.

Note that many views don't have their own settings, so this would be empty = null.

ITypedItem Settings { get; }

Property Value

ITypedItem