Is there a way to change where custom designer views for widgets are located?
The default location is:
I would like to override that if possible. Has anyone done this before?
Here's the guide I'm referencing that specifies that requirement: http://docs.sitefinity.com/feather-create-custom-designer-views
It does not seem that Sitefinity is using the VirtualPathProviderViewEngine for loading the DesignerViews. Here's some new code I wrote: http://pastebin.com/rSJKnJga
I put a breakpoint in every overridden method when trying to see the designer view for the widget, and a relevant view was not searched for or created by the ViewEngine.
I started really digging into the difference between the ways the designer views are called when changing the view locations, here's what I found:
(1) edit is clicked on the widget
(2) a call to the following URL is made (always the same URL despite where the designer views are): localhost:53008/.../Navigation
(3) Here's the interesting part, the response back from that URL differs with a directive used on the html that's returned. When I put my designer views where I want them to be this directive looks like this:
"<server-data default-view='PropertyGrid' widget-name='Navigation' control-id='532bcbd9-908f-6451-9e80-ff00000c1994' culture='en'></server-data>"
Whereas if I put the designer views where Sitefinity wants them, it looks like this:
"<server-data default-view='NavigationView' widget-name='Navigation' control-id='532bcbd9-908f-6451-9e80-ff00000c1994' culture='en'></server-data>"
So, whatever is setting the values of that directive in the responding html is what seems to dictate where my designer views are, or how it finds them? I hope this helps.
Thanks for the link to that post. It was helpful. I was actually inheriting from RazorViewEngine to begin with, and it was good to see an example of inheriting from VirtualPathProviderViewEngine.
Unfortunately it is still not working, here's a link to my current code: http://pastebin.com/HiMjdquD
I do have my Application_Start calling "ViewEngines.Engines.Add(new WidgetFolderViewEngine());"
What's interesting is Sitefinity is picking up the main view that I dictate for the widgets, but not the designer views. It only picks up the designer views when they're under "~/Mvc/Views/1/DesignerView.0.cshtml, and not at my custom route.
So is there a way to get the designer views picked up at a custom location? My current custom location is "~/Widgets/1/Views/0.cshtml".
I wonder if the view engine isn't picking up these designer views because it's confused by the extra dot in it's full name?
WidgetFolderViewEngine : VirtualPathProviderViewEngine
/// Initializes a new instance of the <see cref="WidgetFolderViewEngine"/> class.
 widgetFolderFormats =
// 1 Widget name 0 View name
// For embedded views use Frontend virtual path following the assembly name
var dirs = Directory.GetDirectories(System.Web.HttpContext.Current.Server.MapPath(
var folderName = Path.GetFileName(dir);
// log ex or handle it differently
.AreaViewLocationFormats = widgetFolderFormats;
.AreaMasterLocationFormats = widgetFolderFormats;
.AreaPartialViewLocationFormats = widgetFolderFormats;
.ViewLocationFormats = widgetFolderFormats;
.MasterLocationFormats = widgetFolderFormats;
.PartialViewLocationFormats = widgetFolderFormats;
var widgetNameFormats =
i = 0; i < folderFormats.Length; i++)
format = folderFormats[i];
format = format.Replace(
widgetNameFormats[i] = format;
folderFormats = widgetNameFormats.Concat(folderFormats).Distinct().ToArray();
Say I have a designer view located at "~Widgets/Navigation/Views/DesignerView.Simple.cshtml", I would like to have a script for that located at "~/Widgets/Navigation/Scripts/designerview-simple.js".
Thanks in advance.