Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Frank Fisher 8 posts 28 karma points
    Apr 09, 2013 @ 16:06
    Frank Fisher
    0

    MVC master pages in 6.02+ - when they're amended, they vanish!

    Is this a bug or is my understanding of MVC really deficient? If I produce a new template via the GUI, set a subpage to inherit from it. And then alter the 'master', it moves out of Views, and into Masterpages - wtf? Unless I manually move it back, I'm confronted with YSODs. Should this be happening? Is there a fix?

     

    I'm not sure if I'm using these views correctly - should the master have any 'content' at all, or should it just be built up of partial views?

  • gary 385 posts 916 karma points
    Apr 09, 2013 @ 21:16
    gary
    0

    Hi Frank

    If you have your site set up in MVC, ie have altered the config to run MVC, then you should not need to have views inheriting from a master.

    In Templates folder create a Layout.cshtml, calling @RenderBody, in the View you create ie docType + template , call the layout (Umbraco will put a layout=null at the top of a new view), change that for the layout you made and on "run", the view will wrap the layout around it. (So if you think in terms of webforms that is the master - the view is inherited by the layout call, but the difference is, they are both views, one layout view, the other content page, a view) Hope that makes sense.

    All views should remain in the Views folder, I have never tried but that may be a webforms function that allows you to create a subpage, hence then saving it into masterpages.

    A layout can contain a partial view, I use navigation on a partial in the Layout. (Create in partials folder and call @Html.Partial("nameOfPartial"))

    Always create a new template or Partial via Umbraco, I created some directly in VS and some parts of Umbraco were not aware the view existed.

    A content view can contain numerous partials, ie a sidebar, common content etc. . . 

    Each content page can call a Layout, or no layout, so each page must be told what is it's Layout, (ie Master). So maybe if you think of it as a view is given its master rather than the master inheriting as before.

    Have tried to explain in simple terms, hope that it is not patronising, aplogies if you feel it is, but it is difficult sometimes to strike the right balance. We are all intelligent beings here, but the lack of documentation can make it difficult to grasp the real basics which trips us all up at some point. Anyway, documentation will improve I'm sure, but there is always a friend here somewhere who can help.

    myLayout.cshtml (say header, navigation etc)

    ContentPage (View.cshtml) (Properties from DocType)@{Layout=~/myLayout.cshtml)

    myLayout.cshtml(footer)

    If I can do anymore, give me a shout.

    Regards

    G

     

  • Frank Fisher 8 posts 28 karma points
    Apr 10, 2013 @ 10:47
    Frank Fisher
    0

    My head is spinning.... I wish this was documented! Umbraco TV is great but there is NOTHING about MVC templating.

     

    Gary thanks, I'll try to work through this and puzzle out what you mean, simplistic terms are what I need, I'm a beginner re MVC.

     

    One thing that might help Gary is some actual code? Code for your hierarchy of pages, or screenshots?

  • gary 385 posts 916 karma points
    Apr 10, 2013 @ 11:05
    gary
    0

    Hi Frank

    When I first started down the MVC route, because of the changes to Umbraco that were introduced in Version 5, I used the videos on razor for asp.net MVC.

    http://www.asp.net/web-pages/videos/aspnet-razor-pages/creating-a-consistent-look-(part-1) this demonstrates what I quickly tried to explain.

    I built a sample in WebMatrix as per the videos, then transferred this into Umbraco. 

    Simply, if you say that Umbraco = content, then layout, views, partials are all MVC, the methods are "almost" identical.

    Certainly the video will help, along with others, ok I think they are Razor V1, but the changes are minimal, but if you get the "structure" you can ask the specifics here and are sure to get an answer.

    What I will say is that the work that has been completed to get Umbraco to this point is excellent, yes the lack of documentation is frustrating, but that is why many people help out on this forum, we have a great free product, which allows us as developers to build pretty much without limits. 

    If it gives you any confidence, one year ago I couldn't even write html code, learnt everything about MVC and razor, integration with Umbraco via videos and this forum. So am more than happy to repay my debt to all those people who educated me for free, by helping others in my position.

    Have a great day and enjoy the journey.

    Gary

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Apr 10, 2013 @ 11:08
    Dave Woestenborghs
    0

    The video's on the new umbraco.tv site are about MVC templates : http://beta.umbraco.tv

    You should be able to login with your existing umbraco tv account.

     

    Dave

  • Frank Fisher 8 posts 28 karma points
    Apr 10, 2013 @ 11:34
    Frank Fisher
    0

    Thanks again Gary - and please dont' think for one second I'm disparaging the work people do to build Umbraco.

     

    Dawoe, my login doesn't work there - it works fine on the old videos; is there something I need to do to enable it?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Apr 10, 2013 @ 11:44
    Dave Woestenborghs
    0

    Hi Frank,

    Don't know. Just worked for me. Maybe you can contact Warren Buckley (@warrenbuckley) or Tim Geyssens (@timgeyssens) on twitter. Maybe they can help you out ?

  • Morgan K. 16 posts 57 karma points
    Jun 26, 2013 @ 16:56
    Morgan K.
    1

    I'm having the same issue with the 'cshtml' being changed to 'master' and it being moved into the 'Masterpages' folder.  I've created views as sub-items under the "layout" view, and I've just created all cshtmls on their own, and changed the layout= null to the 'layout.cshtml'.  In both cases, it changes the cshtml to master and moves it to the 'Masterpages' folder.

    After that, all of my one-in pages are YSOD with a message that the Layout.cshtml cannot be found in the views folder.  Has anyone else run into this, or been able to replicate the issue? I'm on V6.1.1..

  • Eric Schrepel 161 posts 226 karma points
    Nov 25, 2013 @ 23:37
    Eric Schrepel
    1

    I was experiencing the same thing today (Umbraco 6.1.6), but only for one template; every time I'd save it in the UI, it would move to masterpages/master.master instead of staying in Views/master.cshtml.

    Turns out I hadn't gotten rid of  all the WebForms code (like any <umbraco field:...> or <asp:...> types of stuff, so it was automatically moving it to masterpages.

    Would be great if a warning box would appear when saving an MVC template that has remnants of WebForms code; as it is, there's no indication it's moving, except that the website stops working.

Please Sign in or register to post replies

Write your reply to:

Draft