Place Dynamic Content Type Widget Template Inside Resource Package - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Place Dynamic Content Type Widget Template Inside Resource Package

  • Place Dynamic Content Type Widget Template Inside Resource Package
  • f337511e-37c1-6deb-a958-ff0000446526_control-templates.png

    I'd like to customize a widget created for a dynamic content type: 

    Productions Production (module, content type)

    I'd like it to only work with the Bootstrap resource package. I know a template is generated by feather when i saved the dynamic content type, and I see it listed and editable from:

     /Sitefinity/Design/ControlTemplates

    (attached is an image showing the screen)

     But what I want is to customize the template only for the bootstrap resource package; and include it there like I the convention seems to be.

  • ResourcePackages/Bootstrap/Productions/List.Production.cshtml

     did not work

  • Hi Merritt,

    Please try 
    ResourcePackages/Bootstrap/MVC/Views/Production/List.Production.cshtml

    The convention requires that: 

    1. Widget templates are under MVC/Views/[content type in singular] 
    2. Template names start with "List." or "Detail.". They will appear in the dropdown in the List or Single item settings respectively.

    Please note that if you have the same template name in Backend and in the file system (i.e. List.Production.cshtml), the latter will take precedence.

    Let me know if it still doesn't work as expected.

    Mariush

  • That works. However you should note that to override in the file system its' actually:

    MVC/Views/[Developer name of content type]/List.[Display name of content type].cshtml

     This is important to note when you create content types with spaces in the name. For instance: 

    My Content Type

    Would be:

    MVC/Views/​MyContentType/List.​My Content Type.cshtml

    and

    MVC/Views/​MyContentType/​Detail.​My Content Type.cshtml​

     

  • Basic: Most built in widgets have template selectors. For instance, say you want an additional template for News Listings for your bootstrap package. You can just drop the cshtml file in the ResourcePackages/Bootstrap/Mvc/Views/News/ folder, but make sure it starts with List, e. g. List.MyNewsList.cshtml should work. The Dynamic Content Widget works this way as well.

     

    More technical: when you look at the news controller, you'll see a property ListTemplateName. This can be set via the widget designer. well how does the designer code, which is a hodge-podge of razor and bootstrap and angular, know what are the possible templates? Look at the following code:

     

    <div class="form-group">
        <label for="newsTemplateName">@Html.Resource("ListTemplate")</label>
     
        <div class="row">
            <div class="col-xs-6">
                <select id="newsTemplateName" ng-model="properties.ListTemplateName.PropertyValue" class="form-control">
                     @foreach (var viewName in Html.GetViewNames("News", @"List\.(?<viewName>[\w\s]*)$"))
                     
                         <option value="@viewName"> @viewName</option>
                     
                </select>
            </div>
        </div>
    </div>

    The helper method Html.GetViewNames is how. Also, notice the matching expression it uses to find the templates.

     PS: I cannot overly stress how important it is for anyone implementing feather to get real intimate like with the feather-widgets project. I have all my developers keep a local copy of the project and keep it open as a reference. 

     github.com/.../feather-widgets

     

  • Is it possible to create multiple views this way or is it only possible to override the default list and detail template? I prefer this way to sitefinity thunder because I can save the file to source control.

  • Having to create the file manually isn't really spelled out well in the documentation. You should really add something around this section: docs.sitefinity.com/feather-modify-fields-of-a-single-dynamic-content-widget