Support

General Documentation

The CMS comes with several commonly used built-in Snippets.

Snippet Summary
Hyperlink Basic internet hyperlink with optional inner image
Image Basic image tag
MetaDescription Meta description tag
MetaKeywords Meta keywords tag

To create a Snippet:

Once a Snippet is created, you will have the opportunity to customize the Snippet by 4 major sections:

Snippet Information

This section contains the follow general information about the Snippet:

Template

Not to be confused with CMS Layout Templates, a Snippet Template is how a Snippet and it's Values should be rendered on the web site. There are two ways to provide a Template.

Inline Markup

When a Template is entered as inline, you can insert placeholder tokens in the desired location each Value or Snippet should appear. The format for these tokens are:

Razor File

To use a ASP.Net Razor file (.cshtml) instead to provide the Template, provide the path to the .cshtml file. It is recommended to place .cshtml files in _private folders. Below is an example of a .cshtml file used as a Snippet Template.

@model ConnectedApps.Cms.Entities.Snippet.SnippetGroupViewModel 
 
<div class="@(Model.Values["BlockColor"].Value.ToString()) @(Model.Values["ImageOrientation"].Value.ToString())">
  <div class="row">

    @if (Model.Values["ImageOrientation"].Value.ToString() == "Image-Left" && Model.Values["Image"].Value != null)
    { 
        <div class="col-md-4 col-sm-4 col-xs-12 xs-hide">
          <img src="@(Model.Values["Image"].Value.ToString())" />
        </div>
    }
    <div class="@(Model.Values["ImageOrientation"].Value.ToString() == "Image-None"? "col-md-12" : "col-md-8 col-sm-8 col-xs-12" )">
      <h3>@(Model.Values["Title"].Value.ToString())</h3>
      @(MvcHtmlString.Create(Model.Values["Content"].Value.ToString()))
      @if(Model.Values["Link"].Value != null && Model.Values["LinkText"].Value != null)
      { 
          <a href="@(Model.Values["Link"].Value.ToString())">@(Model.Values["LinkText"].Value.ToString())</a> 
      }
    </div>
      @if (Model.Values["ImageOrientation"].Value.ToString() == "Image-Right" && Model.Values["Image"].Value != null)
      {
        <div class="col-md-4 col-sm-4 col-xs-12 xs-hide">
          <img src="@(Model.Values["Image"].Value.ToString())" />
        </div>
      }
  </div>
</div>

The rendering engine will pass the Razor view a model of type ConnectedApps.Cms.Entities.Snippet.SnippetGroupViewModel.


Figure 1.

Figure 1 shows the class diagram for the view model passed into the Razor file.


Figure 2.

Figure 2 shows the class representing the Dictionary value.

The benefits of using a custom Razor file as a Template are:

Snippet Items

A Snippet item consist of either a Value or another Snippet.

To add a Value to a Snippet's Items:

To add a another Snippet to a Snippet's Items:

The order in which elements (Value or Snippet) in Snippet Items are shown to the content editor can be rearranged by dragging the element's handle and positioning it in the desired sort order.

Each element can be assigned an Alt Name by placing the cursor to the right of the element's Name. Alt Names are shown to the content editor and in the case of duplicate Values, are used as a token reference in a Snippet's Template.

If an element is a Snippet, then these additional settings are available:

If an element is a Value, then these additional settings are available:

Includes

Must like the Includes collection on a CMS Item, a Snippet can be configured to have Style and Script dependencies. Unlike the CMS Item's Includes, Snippet Includes do not undergo a publish event in order for them to take effect. Any change to a Snippet's includes are immediately effective. By registering includes on Snippets, you can build and package reusable modular blocks of HTML that encompasses how a content editor can provide values and how the resulting markup is presented by a web site visitor.