Can I override views embedded views with my custom views?

37 views
Skip to first unread message

Kevin

unread,
Jun 30, 2011, 12:49:54 AM6/30/11
to MVC Turbine
I am new to MvcTurbine, so this may (or may not) be a dumb question.

I have an application that has the basic (in terms of layout, skin and
functionality) for different customers applications. The best
scenario: a customer feels OK with that base project and nothing
further has to be done for him.

But in most of the cases, a customer might want a particular view or
the logic in a controller look a bit different.

So for instance, if the home page for the base project has a certain
layout, but one of the customers would like to see it slightly
differently, I would like to have the Index.aspx view (corresponding
to the home) defined in the project for that customer, that will
override the one defined in the base project. So the ViewEngine, when
running that application, will use the Index.aspx defined in the
project, and not the one referenced (embedded) in the base project.

If I put the Index.aspx in my custom project as Build Action=Content,
it will always go to the embedded view in the referenced assembly.
If I put the view in my custom project as Build Action=Embedded
Resource, it will throw the error:

"Sequence contains more than one element" since apparently does not
know which one to use.

Is this scenario possible with MvcTurbine? Is it beyond MvcTurbine's
scope?

Javier Lozano

unread,
Jun 30, 2011, 10:22:38 AM6/30/11
to MVC Turbine
Unfortunately, with the ways Embedded Views where done that's not
currently possible. It was mostly meant to be simple scenarios for
all packaged files. However, I don't foresee this being a big change
or that much trouble to implement what you're requesting.

Other people have asked for this feature, so I'm putting it on the
list to tackle next (v3.4). There are other issues with Embedded Views
and virtual pathing we need to address as well.

Darren Cauthon

unread,
Jul 1, 2011, 1:14:59 AM7/1/11
to mvctu...@googlegroups.com

Kevin,

I don't know your exact situation do I'm not sure if this will help, but I will say that I do some similar stuff with the aid of MvcTurbine and the existing conventions around mvc views.  Here is what I have:

A basic site layout including a master page, css, scripts, etc.
A defined way to render a list of items, like a grid.
A defined easy to render a form, with date pickers, html editors, etc.
A need to extend this app to make project-specific administration.

I use turbine's embedded views to store the master page and default editor and display templates.
I use turbine's meta data attributes to allow control over how editor fields are rendered (like, say, whether to show a string property as a text box or a html editor.
I use turbine's global filter registry to set the master page to my embedded master page.
I put all of my stuff into the Shared directory, which allows it to be overridden on a per-controller basis (shared is used last, and mvc does not see the difference between Shared folder in the project and Shared in the embedded view assembly)

They way that I do it still requires that other coders build their own views for each of their actions, but those views only contain a call to Html.DisplayForModel() or Html.EditorForModel().

If this sounds like it could be helpful, I can give more details.

Darren

Reply all
Reply to author
Forward
0 new messages