custom MVC widget template not working - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

custom MVC widget template not working

  • custom MVC widget template not working
  • I followed to the letter the directions found at github.com/.../Work-with-widget-templates for adding a custom template for use with the MVC news widget.  However, whenever I attempt to change the template used for a news widget on one of my pages, the template I created is not in the drop down list.  Has anyone out there successfully added their own custom template for a MVC news list?  If so, please help.  I am finding that Telerik's tutorials for Sitefinity and Feather are less than accurate and generally unhelpful.
  • Hi Tim,

    I am sorry the guide did not work for you. I tried the same article and recorded a short video with the main steps. Everything worked as expected.

    www.screencast.com/.../yvmWb5uRTi0

    Please let me know if it still doesn't work for you or your have encountered problem with other of the guides.

     Best,

    Mariush

  • Mariush,

    Thank you for your reply.  I viewed your screencast, and I did exactly what you did.  The custom template simply does not display in the dropdown.  Is this possibly because I am running the trial?

  • No, it can't be the trial.

    Have you tried with some other widget? If not, can you try with let's say, the Navigation widget?

    Also, please double check your page is based on the package you are modifying. I.e. if your page uses Foundation.default template, you should work in ResourcePackages\Foundation\MVC\Views\[widgetname]

  • The fact that I am just testing Sitefinity and am not very familiar with its design paradigm and such is likely why I am having trouble.  I have defined a custom layout in Visual Studio to use for my pages, so, based on your last post, apparently I have not based my layout on any of the packages.  Could you point me toward a tutorial about using the built in packages when defining a custom layout?
  • The place you put the layout on the file system defines whether it is part of the package and which one. 

    See this one for a general explanation about packages and let me know if you have more questions:

     github.com/.../Page-templates-based-on-layout-files-with-Feather

  • So, to clarify, if I want to base my layout  on the Bootstrap package, I need to create my layout under the "ResourcePagkages/Bootstrap/MVC/Views/Layouts" folder instead of the "MVC/Views" folder right under the solution root?
  • Yes. Once you create the file (let's say it called TimsLayout.cshtml), Sitefinity will register it as a custom page template with name Bootstrap.TimsLayout.cshtml and any pages using that page template will be using that layout.
  • Mariush,

     Thank you so much for your help.  You have been more helpful than anything I have read from Telerik.  Using the info you provided, I was able to deduce that I could create a News folder under the MVC/View folder and place my template in there.  That worked.  It is good to know that I can just move the views I created to any of the included package folder structures and inherit their templates.

  •  I am happy it worked. We will be working to improve the documentation and the initial experience for new users. If you have feedback about other topics that are not explained clear enough, please let me know.
  • Mariush,

     Now that I have the template working, I'm trying to display a custom field that is an image.  Can you please point me to a tutorial that shows how to accomplish that in a custom MVC widget template?

  • Hi,

    Here's a guide how to add a related news item:

    github.com/.../Add-related-data-to-News-widget

    In your case, you need to add related media of type Image and access its properties in the template. To see the full list of properties of the Image item, please refer to Sitefinity API reference.

    If you rather prefer a working sample, create a Dynamic content type with an image field. Sitefinity will auto-generate a widget with templates for it. Then go to Design -> Widget templates and have a look how your related data image field has been rendered in the the detail template for that widget.

    I hope this helps,

    Mariush

     

     ​​

  • Hey Mariush,

     

    I have an issue like that as well.

    I Created a fully new Module with the Module Builder.

    On custom field is an Imagefield and it renders it fine in the DetailsView BUT i also want to have the Picture in the ListView!

    How can i handle this?

  • Hi Dirk,

    When you have created Dynamic content type with an image field  the Sitefinity will auto-generate a widget with templates for it. Then go to Design -> Widget templates and have a look how your related data image field has been rendered in the the detail template for that widget. Than add that code to your list template.

    Note that in the Details view the model is an item but in the List view it is a list of Items, so you need to slightly change the code (screenshot).

    I hope this helps.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items