+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / Place Dynamic Content Type Widget Template Inside Resource Package

Place Dynamic Content Type Widget Template Inside Resource Package

7 posts, 1 answered
  1. Merritt
    Merritt avatar
    31 posts
    Registered:
    11 Mar 2011
    19 May 2015
    Link to this post

    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.

  2. Merritt
    Merritt avatar
    31 posts
    Registered:
    11 Mar 2011
    19 May 2015
    Link to this post

    ResourcePackages/Bootstrap/Productions/List.Production.cshtml

     did not work

  3. Mariush
    Mariush avatar
    43 posts
    Registered:
    08 Aug 2014
    19 May 2015 in reply to Merritt
    Link to this post

    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

    Answered
  4. Merritt
    Merritt avatar
    31 posts
    Registered:
    11 Mar 2011
    19 May 2015 in reply to Mariush
    Link to this post

    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​

     

  5. Jurgen
    Jurgen avatar
    11 posts
    Registered:
    11 Oct 2011
    20 Jul 2015
    Link to this post

    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.

  6. Merritt
    Merritt avatar
    31 posts
    Registered:
    11 Mar 2011
    20 Jul 2015 in reply to Jurgen
    Link to this post

    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. 

     https://github.com/Sitefinity/feather-widgets

     

  7. Adam
    Adam avatar
    23 posts
    Registered:
    05 Apr 2013
    04 Aug
    Link to this post
    Having to create the file manually isn't really spelled out well in the documentation. You should really add something around this section: http://docs.sitefinity.com/feather-modify-fields-of-a-single-dynamic-content-widget
7 posts, 1 answered