Where to put views in Dinamico?

Topics: Developer Forum
Developer
Jun 20, 2012 at 7:08 AM

I see there are views defined in all sorts of places, such as:

  • ~/Dinamico/Themes/Default/Views/ContentPages/XXX.cshtml
  • ~/Dinamico/Themes/Default/Views/ContentParts/XXX.cshtml

but then there are also some things in a Shared folder e.g. 

  • ~/Dinamico/Themes/Default/Views/Shared/

This is all very confusing and the documentation in no place I have been able to find explains the layout of these files. 

If for example I define a part such as this: 

    [PartDefinition()]
    [RestrictChildren(typeof(foo))]
    [AvailableZone("Content", "Content")]
    public class CustomPart : PartModelBase
    {
        ...
    }

Where do I put the view file? Can I define it only in my own theme and not in the default theme? Can I define a default theme outside of the Dinamico directory? I feel like I should avoid mixing site-specific parts with the Dinamico directory, but I'm not sure how to do this. 

I assume that I need to put something like this in the view as well:

@model CustomPart
		   
@{ Content.Define(ie => ie.Title = "Text"); }

Coordinator
Jun 20, 2012 at 3:37 PM

The template-first system of defining content assumes the location [ThemeRoot]/Default/Views/[Controller]/*.cshtml where [ThemeRoot] and [Controller] is configurable during startup.

We could add that it automatically scans /Views/[Controller]/*.cshtml, or make this configurable during configuration.

The per-theme thing is quite interesting. I pulled out of that due to complexity the last time around. I think the main question is whether the main scenario is people extending via themes without change to existing code or taking ownership of the site.

Developer
Jun 20, 2012 at 5:23 PM
Edited Jun 20, 2012 at 5:23 PM

Thanks!

> The per-theme thing is quite interesting. I pulled out of that due to complexity the last time around. I think the main question is whether the main scenario is people extending via themes without change to existing code or taking ownership of the site.

Well, it's still not changing existing code, right? It's just putting your new code alongside existing code, and then it gets all mixed up, which triggers my OCD :-)

The problem was that I couldn't figure out where it scans. That is solved, but I still am working on coming up with a workflow in which I can build a plug-in and maintain it in some separate place and then deploy it to multiple N2 instances, without necessarily making it part of N2 itself. I guess I could do that with Nuget somehow.

Jun 26, 2012 at 7:21 PM

I'm still confused. If I wanted to create my own theme (similar to the new Responsive theme which has its own views and _Layout.cshtml file) and have it live in a directory like ~/MyCustomThemes would I do something like this in the GlobalMvcStarter.cs file?

viewEngines.RegisterThemeViewEngine<RazorViewEngine>("~/MyCustomThemes/");

And I would still need a Default theme in the ~/MyCustomThemes directory? Is this correct?

Thanks,

Barry

Coordinator
Jun 26, 2012 at 10:34 PM

Yes, the fallback behavior is to first look in a directory named as the theme, then fallback to "Default" and after that other view engines are invoked (i.e. /Views/Controller/Action).