Skip to main content
Home  ›  Blog

Major View-Update with View Settings, Resources, Indexing and more

Views get a major update with 2sxc 12.02 with View Settings, Resources, Identifier and more. 

View Information on CmsContext

The CmsContext object has a new property View which lets your Razor know everything about the View it's showing, incl. the Name, Id, an Identifier (see below), Settings (see below), Resources (see below) and more. You can read about it it the ICmsView documentation.

View Icon

Previously View-Icons were automatically picked up from the App-folder. They had to be in a file which matched the name of the Template the View used. This had some drawbacks, so now you can also manually the icon you want - either by drag-drop of the file (in which case ADAM will manage it) or by placing it in the App-folder and referencing it with [App:Path]/my-view-icon.jpg.

This is especially useful when using the same Razor template to create different outputs using Identifiers (see below) or View-Settings (see below) as the preview icon should show how that view differs from others. 

View Resources

Previously multi-language resources for Apps were always configured at the App-level, so the resources were shared across all views. This was simple but resulted in very large App-resources, sometimes containing 100 or more values. 

In 2sxc 12.02 you can now configure View-Resources in a flexible way:

  1. Each view can have it's own resources
  2. Views can also share resources
  3. Views can also share a resource Content-Type but have different values (like when a View has a title and two buttons, but 2 different views would need these resources for different purposes)

These new settings can be configured in the View-Configuration. 

Razor can pick up the View Resources on the Resources dynamic object. This is compounded with App-Resources, so it mixes these properties and gives the View-Resources preference. Read about it in the docs.

View Identifier

Often the same Razor-Template is used for many views, just differing by a minor setting. For example, a list of Images or Link-Tiles may have 2, 3 or 4 columns when displaying - which can be done with the same Razor - but the Razor would need to know which View it's showing. 

In theory you could simply use the Name property (CmsContext.View.Name) but that is fragile because the name might be changed to suit the editors and it could also change in each language. So the Identifier is a string-key you can use to help your code decide which things to apply. 

The identifier is on CmsContext.View.Identifier

For more advanced View variations you should prefer the Settings (see below). 

View Settings

If you use the same Razor Template to create different outputs you may want to give each template a set of values configure it. For example, the amount of columns, the primary color and if a CTA should appear or not. 

Now Views can have custom settings all over, just like Apps. Read about it in the docs.

The code can access these Settings on the Settings object which also merges View and App Settings. 

View Search Index

The Search-Indexing of Views was completely reworked. Now most of the Search-Indexing features can be configured directly in the configuration and you can also determine a code-file which does advanced search-indexing configuration. 

Read about the Search-Indexing feature here:

... and way more

I'll try to write about all the new stuff ASAP. But you can of course always just try it from the Github Releases.

Love from Switzerland and Croatia
iJungleboy, Petar and Tonci

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler